You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deploy the store on Vercel using this Next.js template
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"
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!
The text was updated successfully, but these errors were encountered:
Steps to reproduce bug:
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.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:
removeProduct
operation fails, resulting in the following behaviorSolution
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:
getProduct
call to include product option typescomponents/cart/actions.ts
to pass product option types toremoveProduct
removeProduct
to pass product option types to the endpointBlockers
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!
The text was updated successfully, but these errors were encountered: