Hi
I added a code to my product page which shows the items in stock. Problem is, it only shows the first variant of the product. If I change the color of the product for example, the stock value is not updated. The page needs to refresh to show the correct number. I found this code to force a refresh after variant selection:
<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>
This doesn’t seem to work, however.
Anyone knows a trick to force a page reload after variant selection?
I’m using “Empire” theme, sample page: https://www.tembo.ch/collections/1freizeit/products/flsk-cup-auslaufsicherer-kaffeegenuss-unterwegs?variant=39572783497296
Thx