Low stock counter

Solved

Low stock counter

ewancastle
Shopify Partner
6 0 0

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

Ewan Castle
Accepted Solution (1)

Dan-From-Ryviu
Shopify Partner
9527 1913 1948

This is an accepted solution.

Hi @ewancastle 

Have you checked if your theme has an Inventory status block?Screenshot 2024-09-25 at 14.55.37.png

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.

View solution in original post

Replies 5 (5)

Dan-From-Ryviu
Shopify Partner
9527 1913 1948

This is an accepted solution.

Hi @ewancastle 

Have you checked if your theme has an Inventory status block?Screenshot 2024-09-25 at 14.55.37.png

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.

ewancastle
Shopify Partner
6 0 0

I did try this initially, but unfortunately it didn't seem to work in my theme.

Ewan Castle
Dan-From-Ryviu
Shopify Partner
9527 1913 1948

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.

Zel_Minimate
Shopify Partner
46 0 3

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:

  1. Universal Theme Compatibility: Works with all Shopify themes.
  2. No Coding Required: Set up and customize easily without touching code.
  3. Customizable Thresholds: Set your own low stock levels.
  4. Flexible Display Options: Choose where the low stock message appears on your product page. 
  5. Real-time Updates: Stock status changes automatically with inventory.

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

MINIMATE APPS - CUSTOMIZATION & SCARCITY MADE SIMPLE!
Mini Customization Fields: Effortlessly create and manage custom product fields for a personalized product options.
Mini: Cooming Soon | Waitlist : Maximize revenue through waitlists and pre-orders.
Hey! Scarcity Low Stock Counter: Boost sales by displaying low stock message to create a sense of urgency.
Explore Our Apps for Free | 24/7 Dedicated Support for Shopify merchants

Flair-Liam
Shopify Partner
15 1 2

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

Shopify Theme Developer
Flairconsultancy.com
support@flairconsultancy.com