From 44032b26f370d90cb8ac682bf027c94e1c6b21ab Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Tue, 13 Oct 2015 22:38:04 +1300 Subject: [PATCH] CRM-17387 getBillingDefaults function not available to Membership Form I think this might be some mix up in the history of merged & perhaps this function might have been meant to go in favour of anohter. But, the other places in the code that duplicate this are still present - so perhaps not tackled --- CRM/Contribute/Form/AbstractEditPayment.php | 26 +++++++++++++++++++++ CRM/Member/Form/MembershipRenewal.php | 20 ---------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 7fb7a90e40..6c373e3271 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -706,4 +706,30 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co } } + /** + * Get default values for billing fields. + * + * @todo this function still replicates code in several other places in the code. + * + * Also - the call to getProfileDefaults possibly covers the state_province & country already. + * + * @param $defaults + * + * @return array + */ + protected function getBillingDefaults($defaults) { + // set default country from config if no country set + $config = CRM_Core_Config::singleton(); + if (empty($defaults["billing_country_id-{$this->_bltID}"])) { + $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry; + } + + if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) { + $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince; + } + + $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID); + return array_merge($defaults, $billingDefaults); + } + } diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 697ed171c8..b419773ea5 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -726,24 +726,4 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { } } - /** - * @param $defaults - * - * @return array - */ - protected function getBillingDefaults($defaults) { - // set default country from config if no country set - $config = CRM_Core_Config::singleton(); - if (empty($defaults["billing_country_id-{$this->_bltID}"])) { - $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry; - } - - if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) { - $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince; - } - - $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID); - return array_merge($defaults, $billingDefaults); - } - } -- 2.25.1