Render div based on inventory quantity

New Member
1 0 0


I am currently running the following code in the product template, the problem I am having is that the product.variants.first.inventory_quantity returns a string value not an integer.  I have the following code executing when the page first loads.  However this always returns false on first load even when the product is less than 5. 


<div select id="inventory">
           // When the page first renders - render the inventory amount of the product selected
            {% assign product_amount = product.variants.first.inventory_quantity | plus: 0 %}

            // The integer value is checked for less than 5, render - Quantity
            {% if current_variant.inventory_management == 'shopify' and product_amount <= 5 %}
               Only {{ product_amount }} left in stock.

           // if less than 5 render empty string   
            {% else %}
            {% endif %}