Shopify TOTAL inventory of product

PHOTO EMBED

Mon Oct 25 2021 08:00:29 GMT+0000 (UTC)

Saved by @JureWeConvert #liquid #html

  {% capture inventoryTotal %}
  {% assign total=0 %}
  {%for variant in product.variants %}
    {% capture i %}{{ total | plus:variant.inventory_quantity }}{%endcapture%}
    {% assign total = i %}
  {%endfor%}
  {% if total ==< 307 %}
  {{total | minus: 305 }}
  {%endif%}
  {% endcapture %}

<div class="left-in-stock">*only {{ inventoryTotal }} left at this price</div>
content_copyCOPY

https://community.shopify.com/c/shopify-design/need-guidance-if-total-inventory-quantity-for-a-product-is/td-p/610087