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

Removing a product from the cart fails for products with options that aren't of type "DROPDOWN" and for products with no options #3

Open
bradysheridan opened this issue Dec 16, 2024 · 0 comments

Comments

@bradysheridan
Copy link

bradysheridan commented Dec 16, 2024

Steps to reproduce bug:

  1. Spin up a new Ecwid store
  2. Deploy the store on Vercel using this Next.js template
  3. Create 6 products with the following Option configurations
    3.1 No options
    3.2. Option of type "Drop-Down List"
    3.3. Option of type "Radio Buttons"
    3.4. Option of type "Size"
    3.5. Option of type "Checkboxes"
    3.6. Multiple options, one of type "Drop-Down List" and one of type "Size"
  4. Load the example store and test the following process for each of the above products:
    4.1. Add product to cart
    4.2. Try to increase product quantity in cart
    4.3. Try to decrease product quantity in cart
    4.4. Try to delete product from cart

You will notice the following behavior:

  • Everything works as expected for the product with option type "Drop-Down List"
  • For all other products, the removeProduct operation fails, resulting in the following behavior
    • Clicking the increase quantity button in cart doubles the product quantity and adds 1
    • Clicking the decrease quantity button doubles the product quantity and subtracts 1
    • Clicking the remove item button does nothing

Solution
To solve this, we need to change line 558 of lib/ecwid/index.ts to pass the correct product option type(s), instead of hard-coding that value as "DROPDOWN." You can play with this hard-coded value to test other products and see that this is indeed the issue.

A full solution involves:

  • Refactoring the initial getProduct call to include product option types
  • Refactoring the cart actions in components/cart/actions.ts to pass product option types to removeProduct
  • Refactoring removeProduct to pass product option types to the endpoint

Blockers
I can't submit a PR for the full solution because of blindspots in API documentation of the Storefront API. In particular, I don't know what data the remove endpoint expects for products with options of type "CHECKBOX." Similarly, I've gleaned that options of type "SELECT" need to be changed to "DROPDOWN" for the endpoint to work, but want to double check that this is correct.

Finally - thank you for all of your hard work on this repo, it has simplified our project greatly!

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