[I’ve already read a few other questions about this, but they all revolve around different things displaying]
I hope you can help - I’m trying to make the stock count update so that it will display the current # available for the variant that’s been selected. As you no doubt know, regardless of the quantity in stock for other variants, the “in stock” number remains as whatever the first variant’s count was.
I’m only slightly past novice level at coding, and so prefer to add a Custom Liquid block to add liquid code whenever possible in the Theme Editor, instead of hardcoding in the back end (which has to be re-added with every theme version update).
I’m using Craft theme 15.0, here is the code in the block that I have so far. Maybe this can be tweaked? Or does it have to all be done in the back end? I’m not looking for a full page refresh, but if that’s the only option, please advise.
{% assign current_variant = product.selected_or_first_available_variant %}
<div class="inventoryNote form__label">
{% if current_variant.available %}
{% if current_variant.inventory_quantity > 0 and current_variant.inventory_quantity <= 10 %}
In stock: <b>{{ current_variant.inventory_quantity }}</b> available
{% elsif current_variant.inventory_quantity > 10 %}
In stock: <b>10+</b> available
{% endif %}
{% endif %}
</div>
Any help folks can offer is greatly appreciated, thank you!
