Storefront runtime
Invalid selections
Distinguish incomplete, invalid, unavailable, and unmapped runtime states.
A selection is invalid when a required choice is missing, a selected value is unknown, or the combination violates an authored constraint. Invalid is not the same as unavailable or unmapped.
Handle valid: false
{
"valid": false,
"violations": [
"Brass legs cannot be selected with Green Velvet upholstery."
],
"commerce": {
"sku": null,
"variantReference": null,
"cartPayloadJson": null
}
}The exact violation text is authored or produced by validation and may differ from this example.
Storefront requirements
- Disable Add to Cart immediately when
valid === false. - Render all
violationsnear affected controls or in a summary. - Keep the shopper's choices visible unless your product defines a clear repair policy.
- Treat visuals cautiously. The response can still contain the root asset, but choice-triggered visual actions are currently emitted only for valid selections.
Distinguish the failure states
- Incomplete: At least one required choice is missing. Prompt the shopper to continue.
- Invalid: The selection contains an unknown value or violates a constraint. Explain what must change.
- Unavailable value: The availability matrix says a value cannot be combined with the current context. Prevent selection before it creates a conflict.
- Unmapped: The selection can be valid, yet
variantReference,sku, andcartPayloadJsonare null because no commerce row matched. Explain that the configuration is not currently purchasable.
Do not derive completeness from commerce.sku: a complete product may intentionally have no commerce mapping. Derive it from the revision's required choices.
Verify
- Resolve with one required choice missing and confirm cart is blocked.
- Resolve a known incompatible combination and display every returned violation.
- Resolve an unknown choice value and confirm the UI does not crash or select a replacement.
- Resolve a valid but unmapped combination and show a sellability message distinct from a constraint error.