From 423b9af464b99628fe200e863b4cdc2fa39cb215 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Fri, 10 Jun 2016 16:59:50 +0530 Subject: [PATCH] CRM-18399: 'My billing address is the same as above' option goes away when selecting other payment options --- CRM/Contribute/Form/Contribution/Main.php | 8 -------- CRM/Contribute/Form/ContributionBase.php | 14 +++----------- CRM/Core/Payment/ProcessorForm.php | 13 +++++++++++++ CRM/Financial/Form/Payment.php | 7 +++++++ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 31eb6f5415..422137a48c 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -291,14 +291,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $this->buildComponentForm($this->_id, $this); - if (!empty($this->_fields) && !empty($this->_values['custom_pre_id'])) { - $profileAddressFields = array(); - foreach ($this->_fields as $key => $value) { - CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $this->_values['custom_pre_id'])); - } - $this->set('profileAddressFields', $profileAddressFields); - } - // Build payment processor form CRM_Core_Payment_ProcessorForm::buildQuickForm($this); diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 4bd0558559..1e99b778f4 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -622,17 +622,9 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { 'financial_type' => 1, ); - $fields = NULL; - if ($contactID && CRM_Core_BAO_UFGroup::filterUFGroups($id, $contactID)) { - $fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, - NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL - ); - } - else { - $fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, - NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL - ); - } + $fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, + NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL + ); if ($fields) { // unset any email-* fields since we already collect it, CRM-2888 diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index 5e140c2457..27d644e176 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -73,6 +73,19 @@ class CRM_Core_Payment_ProcessorForm { $form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL(NULL, NULL, 'cancel'); } + if (!empty($form->_values['custom_pre_id'])) { + $profileAddressFields = array(); + $fields = CRM_Core_BAO_UFGroup::getFields($form->_values['custom_pre_id'], FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, + NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL); + + foreach ((array) $fields as $key => $value) { + CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $form->_values['custom_pre_id'])); + } + if (count($profileAddressFields)) { + $form->set('profileAddressFields', $profileAddressFields); + } + } + //checks after setting $form->_paymentProcessor // we do this outside of the above conditional to avoid // saving the country/state list in the session (which could be huge) diff --git a/CRM/Financial/Form/Payment.php b/CRM/Financial/Form/Payment.php index 69d4225f09..8e13412d19 100644 --- a/CRM/Financial/Form/Payment.php +++ b/CRM/Financial/Form/Payment.php @@ -48,6 +48,13 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form { */ public function preProcess() { parent::preProcess(); + + // reload and set values of contributionPage + $id = CRM_Utils_Request::retrieve('id', 'Integer'); + if (!empty($id)) { + CRM_Contribute_BAO_ContributionPage::setValues($id, $this->_values); + } + $this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, TRUE); $this->currency = CRM_Utils_Request::retrieve('currency', 'String', CRM_Core_DAO::$_nullObject, -- 2.25.1