Users are seeking to display low inventory warnings (e.g., “ONLY X LEFT”) on product pages in Shopify’s Dawn theme, specifically when stock falls below 5 units.
Initial Solution:
BSS-Commerce provided custom Liquid code to be added via Online Store → Customize → Product Information → Custom Liquid block
Code checks if product.variants.first.inventory_quantity < 5 and displays the count
Positioned between variant options and “Add to Cart” button with custom styling (#D0DF00 color)
Key Refinements:
Updated code to exclude zero inventory items (preventing “ONLY 0 LEFT” when sold out): {% if product.variants.first.inventory_quantity < 5 and product.variants.first.inventory_quantity > 0 %}
Solution works for single-variant products but has limitations
Ongoing Issues:
Code doesn’t update dynamically when switching between variants on multi-variant products
Users want similar functionality in product grids/collection pages (not yet resolved)
Some report the code stopped working after initial implementation
Questions about showing indicators only when exactly 1 unit remains, or hiding display when inventory = 0
Alternative: HeyMerch app suggested for variant-based inventory display, though the custom code solution remains the primary focus.
Summarized with AI on November 6.
AI used: claude-sonnet-4-5-20250929.
Once again, thank you, this is amazing. Only thing, I don’t want it to show if inventory = 0, because then it displays “only 0 left”, I don’t need this information since there is already the “sold out”.
Can we change the parameter to 0<x<5 ? Thank you so much !
Step 2: Go to Product page → product information → add block → custom liquid
Step 3: Paste the code to the block
{% if product.variants.first.inventory_quantity < 5 and product.variants.first.inventory_quantity > 0 %}
ONLY {{ product.variants.first.inventory_quantity }} LEFT
{% elsif product.variants.first.inventory_quantity < 1 %}
SOLD OUT
{% endif %}
This code is not working anymore… nothing appears. Do you have any idea how to fix it ? I’m still looking to display low inventory “ONLY XX LEFT” for variants < 3 units left.
I am using the native low-stock indicator in the Dawn Theme. Please see attached screenshot: when a variant is out of stock, this is already displayed which is great.
All I want to change is to for the low-stock indicator to show when there is 1 left only. How can I change just this?