All things Shopify and commerce
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
Solved! Go to the solution
This is an accepted solution.
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 -%}
<p>Low stock</p>
{%- else -%}
<p>In stock</p>
{%- endif -%}
{%- endif -%}
- Helpful? Like & Accept solution!
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
This is an accepted solution.
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 -%}
<p>Low stock</p>
{%- else -%}
<p>In stock</p>
{%- endif -%}
{%- endif -%}
- Helpful? Like & Accept solution!
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
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?
- Helpful? Like & Accept solution!
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
Hello @ewancastle,
I understand you're having trouble implementing a low stock indicator using liquid code. Instead of wrestling with code that may not be compatible with your theme, I'd like to suggest our Hey!Scarcity Low Stock Counter app as an easier solution.
Our app offers:
With our app, you can achieve the low stock indicator you're looking for without debugging code or worrying about theme compatibility. It's a quick, plug-and-play solution.
You can find our low stock counter app here in the app store.
Feel free to ask if you have any questions about how our app can meet your needs.
Best regards,
Zel
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
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025