From: Eileen McNaughton Date: Mon, 6 Jul 2015 03:21:07 +0000 (+1200) Subject: CRM-16800 towards fixing recurring error, X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4914efffb8b22810906f4cffe7a2bfb65f25c9ac;p=civicrm-core.git CRM-16800 towards fixing recurring error, I am trying to figure out what part of this function membership form needs to share as the form has 2 paths depending on recurring or otherwise. Ideally the create membership function would be used in both cases & recurring which is a small part of the shared function, could be handled separately --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 346776f20c..adaae8a413 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -1286,13 +1286,19 @@ LEFT JOIN civicrm_option_value contribution_status ON (civicrm_contribution.cont /** * Create address associated with contribution record. * + * As long as there is one or more billing field in the parameters we will create the address. + * + * (historically the decision to create or not was based on the payment 'type' but these lines are greyer than once + * thought). + * * @param array $params * @param int $billingLocationTypeID * * @return int * address id */ - public static function createAddress(&$params, $billingLocationTypeID) { + public static function createAddress($params, $billingLocationTypeID) { + $hasBillingField = FALSE; $billingFields = array( 'street_address', 'city', @@ -1313,9 +1319,13 @@ LEFT JOIN civicrm_option_value contribution_status ON (civicrm_contribution.cont foreach ($billingFields as $value) { $addressParams[$value] = CRM_Utils_Array::value("billing_{$value}-{$billingLocationTypeID}", $params); + if (!empty($addressParams[$value])) { + $hasBillingField = TRUE; + } + } + if ($hasBillingField) { + $address = CRM_Core_BAO_Address::add($addressParams, FALSE); } - - $address = CRM_Core_BAO_Address::add($addressParams, FALSE); return $address->id; } diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 87bc4b8a49..863e8ef56b 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -935,10 +935,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // add these values for the recurringContrib function ,CRM-10188 $params['financial_type_id'] = $financialType->id; - //create an contribution address - if ($contributeMode != 'notify' && empty($params['is_pay_later']) && $isMonetary) { - $addressID = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID); - } + $addressID = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID); //@todo - this is being set from the form to resolve CRM-10188 - an // eNotice caused by it not being set @ the front end