Script that refreshes the page with variant change is also updating when I change the quantity

Script that refreshes the page with variant change is also updating when I change the quantity

guilhermealbino
Shopify Partner
22 1 7

I've used the script bellow to update my metafield data in a variant change event.

But it also refresh when I change product's quantity, returning always quantity = 1.

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
$(".no-js-hidden").on("click", function(){
var refreshint = setInterval(function(){
location.reload();
}, 1000);    });   });
</script>

Can someone help me? Thanks

Replies 4 (4)

LitExtension
Shopify Partner
4914 1005 1182

Hi @guilhermealbino,

I really don't understand your question, but the code you sent is not really good.

I checked and it won't help you to update anything. It will reload the page when you click on any class 'no-js-hidden' so there won't be metafield data.

If you want to catch a block, you need to create a separate class for it.

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com
guilhermealbino
Shopify Partner
22 1 7

What I'm trying to do is something that updates the div where the metafields are shown when I change a product's variant. What you said already made me understand why it updates when I change the product's quantity. The quantity field is also of the "no-js-hidden" class.

 

@LitExtension Would you have any way to resolve this issue? I noticed that some fields use the "radio" type;

 

Thanks

LitExtension
Shopify Partner
4914 1005 1182

Hi @guilhermealbino,

Please send your site and if your site is password protected, please send me the password. I will check it.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com
GFW-webAdmin
Shopify Partner
17 1 4

Dealing with similar issue. What was your fix?