fix(magento-product): count items with no customizable_options as added#2641
Merged
Merged
Conversation
The add-to-cart success snackbar reported "0 products added" for products whose backend consumes the submitted entered_options/selected_options into its own field instead of echoing them as Magento customizable_options (e.g. a configurator that persists its state in a custom cart field). findAddedItems required every requested option to round-trip through customizable_options, so such an item — though added — was dropped from addedItems and the plural rendered the "0 products" branch. When the cart item carries no customizable_options there is nothing to match the requested options against, so accept the SKU (+ configurable variant) candidacy already established above instead of dropping the item. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: e1bcd16 The changes in this PR will be included in the next version bump. This PR includes changesets to release 86 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
The add-to-cart success snackbar reports "0 products added" for products whose backend consumes the submitted
entered_options/selected_optionsinto its own field instead of echoing them back as Magentocustomizable_options.findAddedItemsmatches each submittedcartItemagainst the returned cart by SKU and requires every requested entered/selected option to round-trip through the cart item'scustomizable_options. When a backend integration (for example a 3D configurator that persists its state in a custom cart field) leavescustomizable_optionsempty, that match fails, the — in fact added — item is dropped fromaddedItems, and<Plural value={addedItems.length}>renders theother("0 products") branch.Products that submit no
entered_options(the common configurable/simple case) are unaffected, because the match is vacuously true for them.Fix
When the cart item carries no
customizable_options, there is nothing to match the requested options against — so accept the SKU (+ configurable variant/options) candidacy already established earlier in the function rather than dropping the item.Notes
customizable_options(the existing strict entered/selected matching still runs).