New Member
6 0 0

## Need guidance: if total inventory quantity for a product is between 10 and 25, display a m...

Lets say one of my product has 3 variants with the following inventory quantity:

Red = 10 units

Blue = 5 units

Yellow = 5 units

The total inventory quantity for this product = 20.

I am trying to create a condition that says: if total inventory quantity for a product is between the range of 10 and 25, display a message. Specifically I want to display a message on the product within a collection page.

Replies 2 (2)
New Member
6 0 0

## Re: Need guidance: if total inventory quantity for a product is between 10 and 25, display...

Here's what I have to display the total inventory quantity (for all variables) for a given product on a collection page:

```{% assign total=0 %}
{%for variant in product.variants %}
{% capture i %}{{ total | plus:variant.inventory_quantity }}{%endcapture%}
{% assign total = i %}
{%endfor%}
Total Qty Available : {{ total }}

```

I just can't figure out how to say, if {{ total }} quantity available is within a specific numeric range, display a message.

If you know how to do this, your guidance would be much appreciated.

New Member
6 0 0

## Re: Need guidance: if total inventory quantity for a product is between 10 and 25, display...

Think about this more, why wouldn't this work if we assigned the quantity of all inventory for all variants to total:

```{% assign total=0 %}
{%for variant in product.variants %}
{% capture i %}{{ total | plus:variant.inventory_quantity }}{%endcapture%}
{% assign total = i %}
{%endfor%}
Total Qty Available : {{ total }}

{% if total > 50 %}
This product is in good supply.
{% else %}
This product is running low.
{% endif %}```
Top Contributors