Dynamically display product availability (inventory)

Highlighted
New Member
2 0 0

Hey guys,

 

I am trying to update the product availability based on its inventory amount with 'current_variant.inventory_quantity'.

 

This is what I came up with:

 

 

{% if current_variant.inventory_quantity == 0 %}
Out of stock!

{% elsif current_variant.inventory_quantity < 6 and current_variant.inventory_quantity > 0 %}
Only {{ current_variant.inventory_quantity }} left!

{% elsif current_variant.inventory_quantity > 6 %}
In stock!
{% endif %}

 

This code works correctly if inventory amount equals 0. After that the output is always 'Only X left!'

What am I missing?

 

0 Likes
Highlighted
Trailblazer
245 1 51

Hey @julian_witzel 

Did you ever get this figured out? 

I would also like different outputs for 3 possible quantity levels (no stock, 1-3 in stock, 4 or more).

So far I can only get the first 2 options to work. 

 

 

0 Likes