From d90e6c3baa08a8a1bdf38e34c1ead695cc2860c1 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Wed, 6 Nov 2019 17:31:22 +0530 Subject: [PATCH] separate method for email assignment --- CRM/Contribute/Form/ContributionBase.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 85469e4e40..47c629acd6 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -576,22 +576,31 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']); } $this->assignPaymentFields(); + $this->assignEmailField(); + // also assign the receipt_text + if (isset($this->_values['receipt_text'])) { + $this->assign('receipt_text', $this->_values['receipt_text']); + } + } + + /** + * 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)); } - - // also assign the receipt_text - if (isset($this->_values['receipt_text'])) { - $this->assign('receipt_text', $this->_values['receipt_text']); - } } /** -- 2.25.1