Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configurable product with more than one options, after add to cart, AddProductsToCartSnackbar can not get product name #2390

Open
magecommerce opened this issue Oct 18, 2024 · 0 comments

Comments

@magecommerce
Copy link

Describe the Bug

configurable product with more than one options, after add to cart, AddProductsToCartSnackbar can not get product name
Maybe the following logic is wrong.
If there are multiple options, selectedOptions removes only the last matching option.

@graphcommerce/magento-product/components/AddProductsToCart/findAddedItems.ts

let selectedOptions = itemVariable.selected_options
      if (isTypename(cartItem, ['ConfigurableCartItem'])) {
        // Check if the requested options match the selected options
        if (
          !cartItem.configurable_options.every((option) => {
            const foundItem = itemVariable.selected_options?.find(
              (selectedOption) => selectedOption === option?.configurable_product_option_value_uid,
            )

            selectedOptions = itemVariable.selected_options?.filter(
              (selectedOption) => selectedOption !== option?.configurable_product_option_value_uid,
            )

            return foundItem
          })
        ) {
          // console.log("SKU matche, this isn't the configurable")
          return false
        }
      }

WX20241018-110601@2x

Expected Behavior

show product name + has been added to your shopping cart!

To Reproduce

Step 1: Create a GraphCommerce app
git clone -b main --depth 1 https://github.com/graphcommerce-org/graphcommerce.git
mkdir my-project
cp -R graphcommerce/examples/magento-graphcms/. my-project && rm -rf graphcommerce && cd my-project
yarn
yarn codegen
yarn dev

open address: (product with to options)
http://localhost:3000/p/matriarch-s-edges-size-4-6y-gc-469-sock-6y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant