Repository navigation
Leave out attribute values no active SKU has on the product page - #1521
Draft
sbolinger-godaddy wants to merge 1 commit into
Draft
sbolinger-godaddy wants to merge 1 commit into
sbolinger-godaddy wants to merge 1 commit into
Conversation
ProductDetails built each option control from every value on the attribute. A product with five sizes but SKUs in only two offered all five, and choosing one of the other three showed "This combination is unavailable. Choose different options." When the product response includes every SKU with its attribute values, keep only values some SKU has. A URL selection outside the offered values counts as not chosen. A truncated SKU list, an older server, or an attribute no SKU uses keeps every value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: fc6df60 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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.
Summary
Problem.
ProductDetailsbuilds each option control from every value on the attribute, whether or not an active SKU has that value. A merchant may define more values than they stock. For example, a product might define sizes XS to XL but have active SKUs only in XS. Shoppers then see every size. Choosing one with no SKU shows "This combination is unavailable. Choose different options." and disables Add to cart, even though the page offered that choice. We saw this on a live store: 5 of its 8 products offered sizes they couldn't sell.Change. The product response already includes every active SKU with its attribute value names (
gd-commerce-server0.4.0+, up to 50 SKUs). When it does, the page keeps only the values that some SKU has:getOfferedAttributes()filters each attribute's values to those found on an active SKU. It uses the same completeness check as sold-out marking: nohasNextPage,totalCountequal to the loaded SKUs, and every SKU carryingattributeValues. That check now lives in a sharedgetSkuAttributeValues()helper, so the two can't drift apart.?option.size=sasks the shopper to pick a size instead of showing "unavailable."attributeValuesuseProductDetailsOption()andProductDetailsOptionread the filtered values, so custom option controls get the same behavior.Changeset
@godaddy/gd-commerce-storefrontminor. The README anddocs/server-api.mdare updated to match.Test Plan
New tests in
default-design.test.tsxuse a fixture product with five sizes and SKUs in only two:xsandlrender. Choosing L enables "Add to cart, $25.00", and "unavailable" never appears.?option.size=srenders no checked size and a "Select size" button, with no "unavailable" message.hasNextPage: true, all five sizes render.The first two tests fail against
main'sproduct-details-context.tsx(2 failed, 13 passed). They pass with this change. The third passes on both, as expected, because it covers unchanged behavior.pnpm --filter @godaddy/gd-commerce-storefront build,lint,typecheck, andtest(9 files, 133 tests) all pass.🤖 Generated with Claude Code