My Add to Cart Button is not working, gets stuck on Adding...

Dlugo10
New Member
5 0 0

A few weeks back the button was working just fine. I cant add products to the cart from the product page I only can add products to the cart using the fast add to cart. I havent made any changes to my theme's code. Theme is Foodie.

 

When I change the theme it works just fine.

 

https://andesblossom.ca/collections/50-stem-bulk-rose-collection/products/50-cobalt-blue-roses?varia...

 

This comes out in the log when you click the add to cart.

Dlugo10_0-1711638948373.png

 

Replies 10 (10)

MichalKopec
Shopify Partner
55 9 8

In your theme you have a function

 

function id(id) {
    if (typeof id !== 'number' || isNaN(id)) {
      throw new TypeError('Theme Cart: Variant ID must be a number');
    }
  }

 

 In case the variant Id is not a number, it will throw an error. By any chance you've changed variant ids to values that are not numbers?

A developer with more than 10 years of full stack experience. For work inquiries, please send me a private message.
Dlugo10
New Member
5 0 0

No I haven't. Even when you click on a product you can see the variant id on the url. 

MichalKopec
Shopify Partner
55 9 8

The product page form id refers to a string

product-buttons-form-template--21902126481726__main

which can't be converted to a number. 

 

MichalKopec_0-1711643117487.png

 

Whereas on fast add it refers to an input field which holds the numeric value of the variant:

input#formVariantId

 

MichalKopec_1-1711643285329.png

 

A developer with more than 10 years of full stack experience. For work inquiries, please send me a private message.
Dlugo10
New Member
5 0 0

Makes sense! Do you have any idea why is that function taking my id as a string?

MichalKopec
Shopify Partner
55 9 8

The original theme uses that hidden input field as the id of the form. I suppose that is a dynamic assignment after the page paints to the browser. Since the original id of the form is a string. Then something repaints the form and it goes back to the string. I will try to have a look at it, and see the change history of the id attribute of that form.

A developer with more than 10 years of full stack experience. For work inquiries, please send me a private message.
MichalKopec
Shopify Partner
55 9 8

I see it's now working correctly. May I ask you what the issue was?

A developer with more than 10 years of full stack experience. For work inquiries, please send me a private message.
Dlugo10
New Member
5 0 0

Hi Michal, so basically it was a theme bug so I had to contact them for them to solve it. This was the message they sent me before fixing it:

 

It's not working because you didn't have your variants block enabled. Since it doesn't appear you have any variants anyway, I've enabled that block, it does not change the look of your shop at all, and now items can be added to the cart. We're investigating that issue generally in the theme now.

MichalKopec
Shopify Partner
55 9 8

I see, thanks for clarifying. I'm glad they've fixed it quickly!

A developer with more than 10 years of full stack experience. For work inquiries, please send me a private message.

Guleria
Shopify Partner
3089 606 864

I think the issue conflict is with the subscription app because atc works fine on the collection page with a plus button.  
I suggest ask from the subscription app support alternatively you have to debug the issue manually or ask a developer to check it. 

 

- If helpful then please Like and Accept Solution.
- Want to modify or custom changes or bug fix on store Hire me.
- Email: guleriathakur43@gmail.com - Skype: navrocks1 ,
- Try GEMPAGES a great page builder
-Advance Search Filter
Dlugo10
New Member
5 0 0

I also checked the subscription app by disabling it. But it still happening.