First variant is always added to cart.

Highlighted
New Member
2 0 0

I am having trouble with the first variant being added to the cart on every product, no matter which variant I choose.

0 Likes
Highlighted
Shopify Expert
2684 67 841

Hi, 

the reason for this behaviour heavily depends on the theme you're using, whether it was modified, etc. It would be great if you can share your shop address (or put it in your forum profile) and storefront (not admin) password, if you have one enabled for your shop.

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
I am away till Feb-15.
0 Likes
Highlighted
Shopify Expert
10007 116 1818

Generally you'd see this result if the product page has a JavaScript error. The error would likely be preventing the code from selecting the correct variant when an option is changed so by default it adds the first one. 

As noted above, this is something that the forum members would need to see live. 

If you don't want to share the link at least consider posting the errors that you're seeing in the browser debug console (assuming there are any).

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
New Member
2 0 0

Thank you for your replies! There arent any errors being shown. My shop address is tarp-trader.myshopify.com   I have noticed that when I choose a variant to add to cart it will usually add the very first variant. However, if you choose another variant and hit refresh it will add the variant chosen. It will keep adding that variant from then on out no matter which additional variant is chosen.

0 Likes
Highlighted
New Member
10 0 0

Would somebody be willing to help me with the same? It appears the javascript error (Uncaught SyntaxError: Unexpected number) is pointing to the piece of custom code I added to include add to cart buttons for each product on the collections page. My site is eldiablito.myshopify.com 

Any advice?

0 Likes
Highlighted
Shopify Partner
2471 128 397

@mike_acari wrote:

Would somebody be willing to help me with the same? It appears the javascript error (Uncaught SyntaxError: Unexpected number) is pointing to the piece of custom code I added to include add to cart buttons for each product on the collections page. My site is eldiablito.myshopify.com 

Any advice?


Can be a pretty ambiguous error and hard to diagnose without examination,  but since you provided the url I took a quick look

the error is from here

formSelector: '#AddToCartForm--' 4394641784877,

 

which in javascript needs a plus sign to concatenate a string and other types together:

formSelector: '#AddToCartForm--' + 4394641784877,

 

I do customizations like this all the time , any merchant wanting professional help can hire me at paull.newton+shopifyforums@gmail.com 

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes
Highlighted
New Member
10 0 0

Thank you for the quick response but unfortunately the problem still persists even after adding the plus sign. I currently have the product.id in there - would I need to create an additional variant.id or something as well?

0 Likes