Re: Add to cart button not working

Solved

Why is the add to cart button not functioning on the homepage?

Daniel19901
Shopify Partner
296 2 88

Hi, 

 

I made this shop for a customer not a long while ago, but now (maybe related to the apps he added) the add to cart button on the homepage is not working.

Can anyone help ? 

https://odamor.co.il/

 

Thank you in advance!

Accepted Solution (1)

ThePrimeWeb
Shopify Partner
2139 616 526

This is an accepted solution.

Hey @Daniel19901,

 

The issue is regarding the missing spinner in the homepage. I can't figure out why because I don't have the backend, but I can give you a quick fix that should work theoretically. 

 

Go to your theme's "Edit Code" option and look for "product-form.js"

 

ThePrimeWeb_0-1706527809233.png

 

Then look for the following that says

"this.querySelector('.loading__spinner').classList.remove('hidden');

Mine is line 27, but your's could be different.

ThePrimeWeb_2-1706527907275.png

 

Then replace that line with the following

 

try {
  this.querySelector('.loading__spinner').classList.remove('hidden');
} catch(err) {
  console.log('loading spinner unavailable.')
}
Was I helpful?

Buy me a coffee

🙂

Need help with your store? contact@theprimeweb.com or check out the website
Check out our interview with Shopify!

View solution in original post

Replies 4 (4)

ThePrimeWeb
Shopify Partner
2139 616 526

This is an accepted solution.

Hey @Daniel19901,

 

The issue is regarding the missing spinner in the homepage. I can't figure out why because I don't have the backend, but I can give you a quick fix that should work theoretically. 

 

Go to your theme's "Edit Code" option and look for "product-form.js"

 

ThePrimeWeb_0-1706527809233.png

 

Then look for the following that says

"this.querySelector('.loading__spinner').classList.remove('hidden');

Mine is line 27, but your's could be different.

ThePrimeWeb_2-1706527907275.png

 

Then replace that line with the following

 

try {
  this.querySelector('.loading__spinner').classList.remove('hidden');
} catch(err) {
  console.log('loading spinner unavailable.')
}
Was I helpful?

Buy me a coffee

🙂

Need help with your store? contact@theprimeweb.com or check out the website
Check out our interview with Shopify!
Daniel19901
Shopify Partner
296 2 88

@ThePrimeWeb thank you SOO MUCH!!

Rishabh_Tayal
Shopify Partner
22 0 4

I am developing an app for Shopify app store and I am getting the same error when adding the app block from my app to product page. I understand commenting out the spinner code will fix the issue (or putting it in try-catch), but I want to understand what is causing this issue? If my app code is not added, the issue doesn't happen. I can't ask all my merchants to modify this line of code. Any help is appreciated.

ThePrimeWeb
Shopify Partner
2139 616 526

@Rishabh_Tayal,

 

You could use your app to add the "loading__spinner" class into that element so that the error doesn't happen. Never comment out because in the event it works, it wouldn't do the proper function. That is why i put it in a try-catch block.

Was I helpful?

Buy me a coffee

🙂

Need help with your store? contact@theprimeweb.com or check out the website
Check out our interview with Shopify!