Skip to content
Snippets Groups Projects
Unverified Commit 34549323 authored by Seamus Lee's avatar Seamus Lee Committed by GitHub
Browse files

Merge pull request #15314 from jitendrapurohit/dev-1255

#1255 - fix display of email address on pay later contribution
parents 6fb9450f d90e6c3b
Branches
Tags
No related merge requests found
......@@ -561,10 +561,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
$this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']);
}
$this->assignPaymentFields();
$this->assign('email',
$this->controller->exportValue('Main', "email-{$this->_bltID}")
);
$this->assignEmailField();
// also assign the receipt_text
if (isset($this->_values['receipt_text'])) {
......@@ -572,6 +569,25 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
}
}
/**
* Assign email variable in the template.
*/
public function assignEmailField() {
//If email exist in a profile, the default billing email field is not loaded on the page.
//Hence, assign the existing location type email by iterating through the params.
if ($this->_emailExists && empty($this->_params["email-{$this->_bltID}"])) {
foreach ($this->_params as $key => $val) {
if (substr($key, 0, 6) == 'email-') {
$this->assign('email', $this->_params[$key]);
break;
}
}
}
else {
$this->assign('email', CRM_Utils_Array::value("email-{$this->_bltID}", $this->_params));
}
}
/**
* Add the custom fields.
*
......
......@@ -68,9 +68,11 @@ class CRM_Contribute_Form_Contribution_ThankYouTest extends CiviUnitTestCase {
$pageContribution = $this->getPageContribution((($withPendingContribution) ? 2 : 1), $isTestContribution);
$form = $this->getThankYouForm();
$form->_lineItem = [];
$form->_bltID = 5;
$form->_params['contributionID'] = $pageContribution['contribution_id'];
$form->_params['invoiceID'] = $pageContribution['invoice_id'];
$form->_params['email-5'] = 'demo@example.com';
$form->_params['payment_processor_id'] = $paymentProcessorID;
if ($isTestContribution) {
$form->_mode = 'test';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment