Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-18397: Don't add empty billing name to non-existent billing address #8122

Merged
merged 3 commits into from
May 18, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CRM/Event/Form/Registration/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,9 @@ public static function fixLocationFields(&$params, &$fields, &$form) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is largely a duplicate of the contribution function

$fields = $this->formatParamsForPaymentProcessor($fields);

However, there is a possible case where the syntax might diverge when dealing with multiple participants.

In general the contribution code is cleaner because rather than coming up with 100 & one conditions as to why we add or remove the billing fields it simply assumes that if we presented them on the form in the first place then we probably did so in order to save them

}

// 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');
Expand All @@ -1065,11 +1068,12 @@ public static function fixLocationFields(&$params, &$fields, &$form) {
}
}

// 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'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like to remove the first part of this if - on the basis the decision to record a billing_name should be based on whether we collected it - not a field that probably should not exist anyway.

I'd settle for a code comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ie: remove the event->is_monetary part of the condition?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - I think it should go - but like I say - at min a comment to suggest that to the next person

$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;

Expand Down