Closed (duplicate)
Project:
Drupal Commerce SagePay Integration
Version:
7.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Nov 2014 at 14:42 UTC
Updated:
23 Jan 2015 at 22:16 UTC
Jump to comment: Most recent
Comments
Comment #1
hiraethmarkbOne of our customers was experiencing a similar issue, i.e. instances where a persons first name was appearing twice on SagePay, on the Live SagePay server.
I have been able to test the patch using a development copy of the site, with the Sagepay test server. So far I have seen no instances of the repeated first names on the test transactions that have been completed.
I will need to test with some live transactions next, before confirming whether or not the patch fixes the issue.
Comment #2
tim_marsh commentedI can confirm I'm hitting this issue too , it looks like the version in the repo fixes this in a different way by checking the number of elements in the split_name array.
Im wondering if the naming/logic of this could be looked at. its basically saying if Ive got a name line, overwrite firstname and lastname. Could there be edge cases where you'll be overwriting correct data ?
this appears to be the commit that fixes it
Comment #3
kingandyI think the problem is that the function doesn't actually overwrite the $first_name variable - it concatenates to it.
I could be wrong but it seems like Addressfield is now copying first_name and last_name into name_line. If you have your address widgets set to use the separate first_name and last_name fields, when this function is called you'll get duplicate data in the variables.
If it's determined to use the same variable, it needs to scrub it first (
$first_name = '';). Though as it happens there is a PHP function designed to do what that foreach() loop is doing, so we can just replace the whole thing with implode(). And, actually, that removes the need for a count() check. TBH, I'd drop the overwrite in favour of writing directly to the return array:Comment #4
kingandy(No idea whether addressfield does the reverse when the single name_line is in use, btw. For what it's worth, I think it's doing it to preserve data when switching between the widget settings, so it's not impossible.)
Comment #5
kingandyAll of that said, however - this "always using the name_line" principle may be causing issues with name lengths. See #2312791: The BillingFirstnames value is too long.
Comment #6
kingandyActually, on reflection, name_line is now always going to be present so there's no real point in that whole switch.
Maybe this would be better:
Comment #7
kingandySorry to swamp everyone's inboxes with updates, but I've confirmed that since the change to Addressfield, it's always populating name_line, first_name and last_name on save (though unlike commerce_sagepay it interprets a single entered value as first_name). I honestly think the sagepay code can safely use the first_name and last_name properties from the address value, no formatting required. We could actually drop the _commerce_sagepay_format_customer_name() function altogether, but for completeness:
For reference, here's the Addressfield change, from 2012. #1659066: Update all name columns when a name is entered in either full name or first / last name form elements
Comment #8
ikos commentedOK this looks good. My only concern is backwards compatibility is people haven't updated that address field module. Since it was a year ago, I expect we'll be ok.
I'll do a change note when this goes on to note that the updated version of Address field is a dependency.
Let me do some testing that removes this function all together.
Thanks for digging around on this one!
R
Comment #9
ikos commentedClosing now as duplicate of https://www.drupal.org/node/2312791