-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Solidus 2.11 - it's impossible to update a split address name from the backend #4094
Comments
This seems to happen even when not touching the firstname/lastname attributes, even if you just click on "Update" in the Solidus backend. |
Could this lead to being unable to update addresses in checkout? |
By removing
Perhaps this may be an acceptable solution? |
We came across this issue updating to 2.11 as well this week. Trying to work on a fix. |
@seand7565 thanks for the excellent description |
Oh wow. |
If use_combined_first_and_last_name_in_address is false (default) and firstname and lastname are given in the changeset (ie. from a form) we need to make sure that name is set from it, otherwise data will be inconsistent. Closes solidusio#4094
In Solidus v2.11 we still use `false` for this setting. Using `true` in specs per default is giving false positives and issues like solidusio#4094 where not found.
If use_combined_first_and_last_name_in_address is false (default) and firstname and lastname are given in the changeset (ie. from a form) we need to make sure that name is set from it, otherwise data will be inconsistent. Closes solidusio#4094
If use_combined_first_and_last_name_in_address is false (default) and firstname and lastname are given in the changeset (ie. from a form) we need to make sure that name is set from it, otherwise data will be inconsistent. Closes solidusio#4094
In Solidus v2.11 we still use `false` for this setting. Using `true` in specs per default is giving false positives and issues like solidusio#4094 where not found.
Closing, as that preference has been removed and we no longer support v2.11. |
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 setuse_combined_first_and_last_name_in_address
to false, you won't be passing in aname
attribute (instead usingfirstname
andlastname
). But the old address will still have aname
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 aname
attribute, it just uses that instead. So even if you pass in the above example, it will disregard thefirstname
andlastname
and just usename
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 generatedname
only if thename
attribute 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
firstname
orlastname
, 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 falseGo to admin, attempt to change an addresses firstname or lastname.
The text was updated successfully, but these errors were encountered: