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

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!

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”

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.')
}

@ThePrimeWeb thank you SOO MUCH!!

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.

@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.