i made a custom liquid script to change a custom field data based on selected variant. since it is not dynamic i added some lines to reload the page everytime the user click on a variant
but the problem here is that for some reason the page also reload when i click an image
Hi, did you find a solution for the problem? I have the same issue.
Just like you Iâve added a liquid code to show variant metafields on my productpage.
Each time when an image on the productpage gets clicked, the page reloads.
Very annoying!
Anyone has an idea what is wrong with my code? or what i should change?
Hereâs my liquid code:
{% for variant in product.variants %}
{% if product.selected_or_first_available_variant.id == variant.id %}
Can you post a link to the page please? (and the password if itâs password protected).
We need to see what the rest of the code looks like to determine whatâs wrong.
Underneath you can find the URL https://c9048c-3.myshopify.com/products/maris-brown-cacao
If you change the variant from 30x30cm to 60x60cm, or when you click an
image, or when you close the tab âMooi in combinatie metâ the page reloads.
.no-js-hidden is a very generic selector. There are 14 elements with that class on your store.
The piece of code below tells the browser to reload whenever you click on a .no-js-hidden element.
Iâm not sure what exactly you are trying to achieve, but if you are trying to show variant metafields when you change the variant, you can try this: Shopify Dawn Theme: Update variant metafields on variant change - YouTube