goCart.js: Not working with product variants
The script is working on products with one variant, but products with multiple variants like sizes, are not added to the drawer. A few things I’ve noticed:
-
The
<form>tag provided in the documentation works for single variant products, but also kills my variant options. Switching the id back toproduct_form_{{ product.id }}fixes the issue with the options. Regardless of the <form> tag I use, it yields the same results: it will add single variant products to the drawer/cart, but not multi-variant. -
When I remove the
js-go-cart-add-to-cartclass from the submit button, then add the variant product to the cart normally, the product will show up in the drawer when I click the cart icon. The drawer will show all products in the cart, but add-to-cart will only add single variant products. It looks like something might be going wrong with the add-to-cart script when triggered?
I have this implemented on a client site and would love to get this resolved. For now I’m using a condition to add/remove the add-to-cart class depending on if there are multiple variants or not.
{% if product.has_only_default_variant %}js-go-cart-add-to-cart{% endif %}
Regardless of the issues, I’m loving the script so far! Thanks!
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 28 (9 by maintainers)
@cfxd ok looks like with some digging I have sorted it… but one issue is if the button lives inside a div (in this case prd-Product_Buy) then it won’t work can this be fixed? See below:
Errors
Works
@cfxd really thanks for for work you are doing. Im actually thinking about rewriting the goCart.js from the beginning and move away from theme being dependency for variants to work. That would mean that goCart would provide the whole product form and had custom events for handing variations and updating hidden select (like slate v1). If you have any idea or feature you think would be great i would be more than happy to share some emails with you.