diff --git a/packages/theme/modules/catalog/product/components/product-types/configurable/ConfigurableProduct.vue b/packages/theme/modules/catalog/product/components/product-types/configurable/ConfigurableProduct.vue index 1117710ea..b57b7b285 100644 --- a/packages/theme/modules/catalog/product/components/product-types/configurable/ConfigurableProduct.vue +++ b/packages/theme/modules/catalog/product/components/product-types/configurable/ConfigurableProduct.vue @@ -131,7 +131,7 @@ v-e2e="'product_add-to-cart'" :disabled="isCartLoading || !canAddToCart(product, qty) || isFetching" class="product__add-to-cart" - @click="addItem({ product, quantity: parseInt(qty) })" + @click="addItem({ product, quantity: parseInt(qty), productConfiguration })" /> { @@ -61,8 +62,7 @@ export const addItemCommand = { .addProductsToCart .cart as unknown as Cart; case 'ConfigurableProduct': - const selectedOptions = product.configurable_product_options_selection.options_available_for_selection - .flatMap((attr) => attr.option_value_uids); + const selectedOptions = Object.values(productConfiguration as object); const configurableCartInput: AddProductsToCartInput = { cartId, diff --git a/packages/theme/modules/checkout/composables/useCart/index.ts b/packages/theme/modules/checkout/composables/useCart/index.ts index 80c4da71e..c573572ec 100644 --- a/packages/theme/modules/checkout/composables/useCart/index.ts +++ b/packages/theme/modules/checkout/composables/useCart/index.ts @@ -122,7 +122,9 @@ PRODUCT } }; - const addItem = async ({ product, quantity, customQuery }): Promise => { + const addItem = async ({ + product, quantity, productConfiguration, customQuery, + }): Promise => { Logger.debug('useCart.addItem', { product, quantity }); try { @@ -136,6 +138,7 @@ PRODUCT currentCart: cart.value, product, quantity, + productConfiguration, customQuery, }); diff --git a/packages/theme/modules/checkout/composables/useCart/useCart.ts b/packages/theme/modules/checkout/composables/useCart/useCart.ts index 96073ff91..8cd34e645 100644 --- a/packages/theme/modules/checkout/composables/useCart/useCart.ts +++ b/packages/theme/modules/checkout/composables/useCart/useCart.ts @@ -8,6 +8,7 @@ import { Product } from '~/modules/catalog/product/types'; export type UseCartAddItemParams = ComposableFunctionArgs<{ product: PRODUCT; quantity: number; + productConfiguration?: { [key: string]: string }; }>; /**