-
-
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
Assign default user addresses in checkout controller #1967
Assign default user addresses in checkout controller #1967
Conversation
It fixes solidusio#1811: when cart -> address state change happens and user is not yet logged in, the `assign_default_addresses!` callback will not associate any address to the order regardless if the user will immediately later perform a login and had some address associated. By calling `assign_default_addresses!` method in the `before_address` checkout controller's callback we'll be sure we always set addresses correctly before entering the address step.
337af88
to
f13d067
Compare
@jhawthorn @mamhoff this is not going to change any value on a GET request. It just sets the address without saving. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good with me, thank you!
Thanks @kennyadsl, I bumped into this problem just the other day. Can confirm this resolves the issue 😀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good
That's great! Thanks so much! It's those small usability things, which are most annoying. Thanks again! |
It fixes #1811:
When cart -> address state change happens and user is not yet logged in, the
assign_default_addresses!
callback will not associate any address to the order regardless if the user will immediately later perform a login and had some address associated.By calling
assign_default_addresses!
method in thebefore_address
checkout controller's callback we'll be sure we always set addresses correctly before entering the address step.The only cons I see is that we call this method much often (every time we hit the checkout address page) but it should be safe since, as @aaronrussell pointed out, it does nothing when the order has no user or when the order already has addresses associated.
I'm not sure if we want to remove the state machine callback now and move this functionality at a controller level, but we'll probably want to add
assign_default_addresses!
to backend and api controllers as well.This PR also adds checkout feature specs that allows to reproduce this issue.