On Solidus 2.11, theres a bug that prevents you from updating firstname and lastname from admin.
It all starts with the addresses value_attributes class method. It combines the old addresses attributes with the attribute changes that you're trying to make. That way, your changes are layered on top of the existing address information. However, if you've set use_combined_first_and_last_name_in_address to false, you won't be passing in a name attribute (instead using firstname and lastname). But the old address will still have a name attribute.
So the combined attributes would be something like: { firstname: 'Bruce', lastname: 'Wayne', name: 'The Batman' }.
On line 88 of the method, we generate a new name with Spree::Address::Name.from_attributes. But if you pass in a name attribute, it just uses that instead. So even if you pass in the above example, it will disregard the firstname and lastname and just use name instead - which comes from the old address.
Additionally
If that were fixed, there's another issue - on line 97 of the value attributes method, you'll see that we only replace the name attribute with the new generated name only if the name attribute is not present. So even if we did generate the correct name above, the new address would still use the incorrect name.
Last note
The address model knows that it needs to generate a new address when you pass in an updated firstname or lastname, so it does that in this scenario... but those attributes don't change. Meaning, you generate an exact copy of the address you're trying to change every time you attempt to change it.
https://www.loom.com/share/37ab0c961dbd4ab9b40e39e8fe4bfff3
Solidus Version:
2.11
To Reproduce
Start a Solidus store on 2.11 from scratch
Set use_combined_first_and_last_name_in_address config to false
Go to admin, attempt to change an addresses firstname or lastname.
On Solidus 2.11, theres a bug that prevents you from updating firstname and lastname from admin.
It all starts with the addresses
value_attributesclass method. It combines the old addresses attributes with the attribute changes that you're trying to make. That way, your changes are layered on top of the existing address information. However, if you've setuse_combined_first_and_last_name_in_addressto false, you won't be passing in anameattribute (instead usingfirstnameandlastname). But the old address will still have anameattribute.So the combined attributes would be something like:
{ firstname: 'Bruce', lastname: 'Wayne', name: 'The Batman' }.On line 88 of the method, we generate a new name with
Spree::Address::Name.from_attributes. But if you pass in anameattribute, it just uses that instead. So even if you pass in the above example, it will disregard thefirstnameandlastnameand just usenameinstead - which comes from the old address.Additionally
If that were fixed, there's another issue - on line 97 of the value attributes method, you'll see that we only replace the
nameattribute with the new generatednameonly if thenameattribute is not present. So even if we did generate the correct name above, the new address would still use the incorrectname.Last note
The address model knows that it needs to generate a new address when you pass in an updated
firstnameorlastname, so it does that in this scenario... but those attributes don't change. Meaning, you generate an exact copy of the address you're trying to change every time you attempt to change it.https://www.loom.com/share/37ab0c961dbd4ab9b40e39e8fe4bfff3
Solidus Version:
2.11
To Reproduce
Start a Solidus store on 2.11 from scratch
Set
use_combined_first_and_last_name_in_addressconfig to falseGo to admin, attempt to change an addresses firstname or lastname.