My store inventory is not updating when customer chooses a new option

My store inventory is not updating when customer chooses a new option

MichaelSquid
Visitor
1 0 0

 

When a customer choose a variant for a product that has a low inventory in stock, it will display a message "Only 1 in stock". The problem is when they choose another variant, the message will stay and confuse our customer to believing there is only 1 left for every single variant. I have a custom liquid block for that and the code i'm using is: 
{% 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 <= 3 %}
Only {{ current_variant.inventory_quantity }} left in stock!
{% else %}
&nbsp;
{% endif %}
{% else %}
&nbsp;
{% endif %}
</div>

P/S: the problem will not occur if they choose a variant with inventory not fall into the if case first. 

Replies 0 (0)