Why doesn't selected variant change the product photo but other times it does?

Solved

Why doesn't selected variant change the product photo but other times it does?

Pajchel
Tourist
13 0 3

I can't figure this out. When I load the page there is a chance that product photos with variants won't work, then I reload the page and then they work, but customer won't be reloading the page to see if it works. Sometimes it doesn't work even after reloading.

Accepted Solution (1)
lynth
Shopify Partner
197 11 33

This is an accepted solution.

I think it can prevent fast clicking on the Add to cart button. Try to click it fast 10 times for example. But in general, it works after commented.

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!

View solution in original post

Replies 5 (5)

lynth
Shopify Partner
197 11 33

Hi, share your URL, please. 

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
Pajchel
Tourist
13 0 3
lynth
Shopify Partner
197 11 33

there is a problem with the resetProductFormState function in your JS file.

 

resetProductFormState() {
  const productForm = this.productForm;
  productForm?.toggleSubmitButton(true);
  productForm?.handleErrorMessage();
}

 


You can see in the console: 

Uncaught TypeError: productForm?.toggleSubmitButton is not a function

If the issue disappears after a page reload, it suggests a timing issue - your script might be running before productForm is properly initialized.




If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
Pajchel
Tourist
13 0 3

What function does it serve? I commented it out and now it seems to be working. Can I live without it?

lynth
Shopify Partner
197 11 33

This is an accepted solution.

I think it can prevent fast clicking on the Add to cart button. Try to click it fast 10 times for example. But in general, it works after commented.

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!