Skip to content

Solidus 2.11 - it's impossible to update a split address name from the backend #4094

@seand7565

Description

@seand7565

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.

Metadata

Metadata

Assignees

Labels

confirmedValidated reportwontfixConfirmed report, but not accepted for some reason

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions