Include selectedOptions in add-to-cart event detail#3854
Open
AboodFares wants to merge 1 commit into
Open
Conversation
buildAddToCartDetail omitted the selected variant's selectedOptions from the product payload, even though it is already tracked in the product form's observable state. Because the cart store spreads this payload into the optimistic line's merchandise, optimistic lines had no selectedOptions to render during the mutation window. Cart line components that render option names (e.g. "Size: Large") could only fall back to the variant title (e.g. "Large / Square"), producing a visible label flicker when the mutation resolved. Adding selectedOptions closes the gap with no consumer-side change, since CartLineMerchandise already supports the field. Fixes Shopify#3853
Author
|
I have signed the CLA! |
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.
WHY are these changes introduced?
Fixes #3853
buildAddToCartDetaildoesn't include the variant'sselectedOptionswhen it builds the add-to-cart detail, even though it's already available on the selected variant. The cart store spreads that payload into the optimistic line'smerchandise, so the optimistic line ends up with noselectedOptions.The effect is a flicker: cart lines that show option names like
Size: Largehave nothing to render during the optimistic window and fall back to the variant title (Large / Square), then snap to the real options once the mutation resolves.WHAT is this pull request doing?
Adding
selectedOptionsto the product payload inbuildAddToCartDetail. Nothing else needs to change since the cart store already spreads the whole payload intomerchandiseandCartLineMerchandisealready has the field. Also updated the existing tests and added one that checks the optimistic detail includesselectedOptions.HOW to test your changes?
All passing.
Checklist