I want to add another status to my inventory status on my website.
For example, by default, if it is over 5pcs in stock it displays “In Stock”, if under 5pcs it says “Low Stock”, however I want to add an additional condition that if there’s only 1pc left in stock it will say “Last Unit” with a red circle too.
Go to Shopify Admin → Online Store → Themes →Edit Code.
Open the file Sections → main-product.liquid
Look for the existing inventory status code. It should be inside a {% if %}condition, typically checkingproduct.variants.first.inventory_quantity.
Modify it to include an “In Stock” message when inventory is available.
Find this section
{% if current_variant.inventory_quantity > 0 %}
{{ 'products.product.stock_available' | t }}
{% endif %}
Modify it like this to display “In Stock”
{% if current_variant.inventory_quantity > 0 %}
In Stock
{% elsif current_variant.inventory_policy == 'continue' %}
Available for Pre-Order
{% else %}
Out of Stock
{% endif %}
If my reply is helpful, kindly click like and mark it as an accepted solution.
Thanks!