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 and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. 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 and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. 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 and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. 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
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024