diff --git a/.changeset/add-products-to-cart-empty-customizable-options.md b/.changeset/add-products-to-cart-empty-customizable-options.md new file mode 100644 index 0000000000..33df737ff7 --- /dev/null +++ b/.changeset/add-products-to-cart-empty-customizable-options.md @@ -0,0 +1,5 @@ +--- +'@graphcommerce/magento-product': patch +--- + +Fix the add-to-cart success message counting 0 when the added cart item has no `customizable_options` to match the requested entered/selected options against. `findAddedItems` now falls back to the SKU (+ configurable variant) match instead of dropping the item. diff --git a/packages/magento-product/components/AddProductsToCart/findAddedItems.ts b/packages/magento-product/components/AddProductsToCart/findAddedItems.ts index b798cc8e24..e9b973af69 100644 --- a/packages/magento-product/components/AddProductsToCart/findAddedItems.ts +++ b/packages/magento-product/components/AddProductsToCart/findAddedItems.ts @@ -48,6 +48,8 @@ export function findAddedItems( } const { customizable_options } = cartItem + // No customizable_options to match against — trust the SKU candidacy rather than drop the item. + if (customizable_options.length === 0) return true const matchEntered = filterNonNullableKeys(itemVariable.entered_options).every( (requestOption) => customizable_options.find(