Hi there, how can I display stock quantities on my website? Dawn version 14.
Hi,
To display stock quantities on your website, follow these steps:
-
Edit Theme Code:
- Go to Themes and click Actions > Edit Code.
- Find the product template file.
-
Modify Code to Display Stock Quantity:
- Open the product template file.
- Find the place where you want to display the stock quantity.
- Insert the following code snippet to display the stock quantity:
{% if product.available and product.variants.first.inventory_management %}
{% assign total_inventory = 0 %}
{% for variant in product.variants %}
{% assign total_inventory = total_inventory | plus: variant.inventory_quantity %}
{% endfor %}
In stock: {{ total_inventory }} items
{% else %}
Out of stock
{% endif %}
@sonnisaar hey,
please use this code where you want to show on product page :
{% for variant in product.variants %}
{{ variant.inventory_quantity }} in stock.
{% endfor %}