I’m looking to implement a low stock string on a product template and basically need to know if it’s achievable.
I’ve been digging through if statements and have found that I can use variant.inventory_quantity.
The code i’ve put in is as follows but doesn’t fire:
{% if variant.inventory_quantity > 20 %}
<p> Low stock</p>
{% else %}
In stock
{% endif %}
Can someone help?
Thanks in advance
Hi @ewancastle
Have you checked if your theme has an Inventory status block?
Or you can try to use this code.
{%- if product.selected_or_first_available_variant.inventory_quantity > 0 -%}
{%- if product.selected_or_first_available_variant.inventory_quantity < 20 -%}
Low stock
{%- else -%}
In stock
{%- endif -%}
{%- endif -%}
Hi Ewan,
This is definitely achievable, we use this in one of our themes.
Try using
{% if first_available_variant_qty => 20 %}
You would also need to ensure this is placed in the relevant section where variant data can be accessed.
Hope that helps!
Liam
I did try this initially, but unfortunately it didn’t seem to work in my theme.
What theme are you using for your store? Could you share your store URL so I can check?