From: JKingsnorth Date: Tue, 12 Apr 2016 15:36:15 +0000 (+0100) Subject: CRM-18397: Don't add empty billing name to non-existent billing address X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=08318d90454742a9b1be20d5a1f59437d6fb35da;p=civicrm-core.git CRM-18397: Don't add empty billing name to non-existent billing address --- diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 0485d4c6a1..1ef3429c1e 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -1052,6 +1052,9 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } } + // If there's no 'first_name' in the profile then overwrite the names from + // the billing fields (if they are set) + // @todo This logic is flawed, at least check each field?? if (is_array($fields)) { if (!array_key_exists('first_name', $fields)) { $nameFields = array('first_name', 'middle_name', 'last_name'); @@ -1065,11 +1068,12 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } } - // also add location name to the array - if ($form->_values['event']['is_monetary']) { + // Add the billing names to the billing address, if a billing name is set + if ($form->_values['event']['is_monetary'] && !empty($params['billing_first_name'])) { $params["address_name-{$form->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params); $fields["address_name-{$form->_bltID}"] = 1; } + $fields["email-{$form->_bltID}"] = 1; $fields['email-Primary'] = 1;