/**
* 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',
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;
}
// 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