All things Shopify and commerce
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 %}
{% endif %}
{% else %}
{% endif %}
</div>
P/S: the problem will not occur if they choose a variant with inventory not fall into the if case first.
Find Global Growth Opportunities For Your Business with Shopify AcademyLearn how to exp...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025