How to reload page when a variant is selected?

upc278999
New Member
9 0 0

We have a modal box that shows variant pricing on product pages. But it only shows the correct variant price if you reload the page. How do I force reload the page when someone clicks on a variant? I tried the code below in product.liquid file but it doesn't work? Any help?

<script>
jQuery(function() {
$('.single-option-selector').on('change', function(){
setTimeout(function(){
if($('[name="id"]').val() != "{{ product.selected_or_first_available_variant.id }}"){
location.reload();
}
}, 1);
});
});
</script>

 

0 Likes