Skip to content

Commit

Permalink
Ensure pay_later variables assigned to template
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Mar 18, 2022
1 parent 742ef03 commit 17087db
Show file tree
Hide file tree
Showing 14 changed files with 3,244 additions and 4,474 deletions.
16 changes: 12 additions & 4 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2812,6 +2812,11 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa
// the way the pcpParams & honor Params section works is a baby-step towards this.
$template = CRM_Core_Smarty::singleton();
$template->assign('billingName', $values['billingName']);
// It is unclear if onBehalfProfile is still assigned & where - but
// it is still referred to in templates so avoid an e-notice.
// Credit card type is assigned on the form layer but should also be
// assigned when payment.create is called....
$template->ensureVariablesAreAssigned(['onBehalfProfile', 'credit_card_type']);

//assign honor information to receipt message
$softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id);
Expand Down Expand Up @@ -2842,10 +2847,10 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa
'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']),
];
}
$template->assign('softCreditTypes', $softCreditTypes);
$template->assign('softCredits', $softCredits);
}
}
$template->assign('softCreditTypes', $softCreditTypes ?? NULL);
$template->assign('softCredits', $softCredits ?? NULL);

$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $this->id;
Expand All @@ -2861,6 +2866,9 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa
$template->assign('price', $productDAO->price);
$template->assign('sku', $productDAO->sku);
}
else {
$template->assign('selectPremium', FALSE);
}
$template->assign('title', $values['title'] ?? NULL);
$values['amount'] = CRM_Utils_Array::value('total_amount', $input, (CRM_Utils_Array::value('amount', $input)), NULL);
if (!$values['amount'] && isset($this->total_amount)) {
Expand All @@ -2875,7 +2883,7 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa
'title' => NULL,
];

if (strtolower($this->_component) == 'contribute') {
if (strtolower($this->_component) === 'contribute') {
//PCP Info
$softDAO = new CRM_Contribute_DAO_ContributionSoft();
$softDAO->contribution_id = $this->id;
Expand Down Expand Up @@ -2918,7 +2926,7 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa
if (!empty($values['softContributions'])) {
$template->assign('softContributions', $values['softContributions']);
}
if ($this->_component == 'event') {
if ($this->_component === 'event') {
$template->assign('title', $values['event']['title']);
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$viewRoles = [];
Expand Down
8 changes: 3 additions & 5 deletions CRM/Contribute/Form/Contribution/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -1400,12 +1400,10 @@ public function submit($params) {
// Would be nice to someday understand the point of this set.
$this->set('is_pay_later', $params['is_pay_later']);
// assign pay later stuff
$this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
$this->_params['is_pay_later'] = $params['is_pay_later'];
$this->assign('is_pay_later', $params['is_pay_later']);
if ($params['is_pay_later']) {
$this->assign('pay_later_text', $this->_values['pay_later_text']);
$this->assign('pay_later_receipt', CRM_Utils_Array::value('pay_later_receipt', $this->_values));
}
$this->assign('pay_later_text', $params['is_pay_later'] ? $this->_values['pay_later_text'] : NULL);
$this->assign('pay_later_receipt', ($params['is_pay_later'] && isset($this->_values['pay_later_receipt'])) ? $this->_values['pay_later_receipt'] : NULL);

if ($this->_membershipBlock && $this->_membershipBlock['is_separate_payment'] && !empty($params['separate_amount'])) {
$this->set('amount', $params['separate_amount']);
Expand Down
6 changes: 2 additions & 4 deletions CRM/Event/Form/Registration/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,8 @@ public function postProcess() {
// assign pay later stuff
$this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
$this->assign('is_pay_later', $params['is_pay_later']);
if ($params['is_pay_later']) {
$this->assign('pay_later_text', $this->_values['event']['pay_later_text']);
$this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
}
$this->assign('pay_later_text', $params['is_pay_later'] ? $this->_values['event']['pay_later_text'] : NULL);
$this->assign('pay_later_receipt', $params['is_pay_later'] ? $this->_values['event']['pay_later_receipt']: NULL);

if (!$this->_allowConfirmation) {
// check if the participant is already registered
Expand Down
Loading

0 comments on commit 17087db

Please sign in to comment.