Repository navigation
Keep the account's checkout attributes when merging a guest cart at login - #935
Merged
Merged
Conversation
…ogin MigrateShoppingCart always wrote the guest's checkout attributes onto the account, even when the guest had none, so logging in from a fresh browser cleared a saved choice such as gift wrapping. The guest's attributes now move only when the guest has some and the account has none in that store.
The account's stored checkout attributes are only cleared when an order is placed, so they can come from a cart abandoned long ago or point at attributes that no longer apply. Keeping them over a selection the customer just made as a guest applied stale choices to the order. The guest's selection now always moves when it has one; the account keeps its own only when the guest has none, which is what the login-from-a-fresh-browser case needs. The tests register the type converters once per class and build stored values through the shipped converter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: bugfix
Issue
When a customer logs in,
ShoppingCartService.MigrateShoppingCartmoves the guest cart onto the account and always overwrote the account'sCheckoutAttributesuser field with the guest's, even when the guest had none. Logging in from a fresh browser (or after clearing cookies) therefore cleared a saved checkout choice such as gift wrapping, and the next order showed "Gift wrapping: No".To reproduce on develop:
Solution
The guest's checkout attributes for the store move only when the guest has selected some. A guest with none leaves the account's own attributes untouched. When both have attributes, the guest's selection wins as before: it is the most recent one, while the account's stored attributes are only cleared when an order is placed and may come from a long-abandoned cart. Cart items and coupon codes are merged as before.
Breaking changes
None. The signature of
MigrateShoppingCartis unchanged.Testing
dotnet test src/Tests/Grand.Business.Checkout.Tests(new cases inShoppingCartServiceTests: empty guest keeps the account's attributes, guest's attributes replace the account's, attributes in another store don't block the move).