I’d really like a solution, if one exists, for the following behavour. I suspect it’s a bug or limitation of the theme/Shopify, but surely there is a workaround of some description?
My store/product is here (password “omicron” without quotes)
If I put the following in product-template.liquid (doesn’t really matter where, but let’s say just below the product description)
{% assign current_variant = product.selected_or_first_available_variant %}
{{current_variant.available }}
Then it is only correct on the first load of a product - i.e. it only applies to the default variant. If that is in stock, then “true” is printed, and if not “false” is printed.
If I choose another variant then it will remain in the previous state. If I load a page with the default (or deeplinked) variant is in stock (“true” is shown) and change to a variant that is not available then it remains “true”.
Is it possible to change it so that current_variant updates?
If I put the following, the sku updates with variant selection without any problems. It’s correct every time, but availability doesn’t update correctly.
{{ current_variant.sku }}
I have also found that bypassing “assign” and using the following does not update like I think it should.
{{ product.selected_or_first_available_variant.available }}
The following code produced the following results with no F5 of the page, just choosing from the stadard Debut product variant selector.
{% assign current_variant = product.selected_or_first_available_variant %}
{% assign in_stock = current_variant.available %}
{{ current_variant.sku }}
{{ current_variant.available }}
{{ product.selected_or_first_available_variant.available }}
{{ in_stock }}
{% unless in_stock %}
false
{% endunless %}


