Skip to content
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

Merged

Conversation

kennyadsl
Copy link
Member

@kennyadsl kennyadsl commented May 24, 2017

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 the before_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.

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.
@kennyadsl kennyadsl force-pushed the assign-addresses-before-address-step branch from 337af88 to f13d067 Compare June 6, 2017 16:01
@kennyadsl kennyadsl changed the title [WIP] Assign default user addresses in checkout controller Assign default user addresses in checkout controller Jun 6, 2017
@jhawthorn jhawthorn self-requested a review June 14, 2017 15:40
@kennyadsl
Copy link
Member Author

@jhawthorn @mamhoff this is not going to change any value on a GET request. It just sets the address without saving.

Copy link
Contributor

@mamhoff mamhoff left a 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!

@kennyadsl kennyadsl self-assigned this Jun 14, 2017
@Sinetheta
Copy link
Contributor

Thanks @kennyadsl, I bumped into this problem just the other day. Can confirm this resolves the issue 😀

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good

@jhawthorn jhawthorn merged commit 4fd6858 into solidusio:master Jun 14, 2017
@mtomov
Copy link
Contributor

mtomov commented Jun 15, 2017

That's great! Thanks so much! It's those small usability things, which are most annoying. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User address not added to order after signing in
6 participants