Shopify themes, liquid, logos, and UX
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?...
Thx
Did you manage to fix this problem? I have the same issue with the Debut theme and color variants. The stock for sizes is correct for the first color, but changing the color has no effect on size swatch.
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025