Hi there, how can I display stock quantities on my website? Dawn version 14.
Topic summary
A user asks how to display stock quantities on their Shopify Dawn version 14.1 website.
Solutions Provided:
Two community members offer code-based solutions:
-
deservefirst suggests editing the theme code by navigating to Themes > Actions > Edit Code, locating the product template file, and inserting a Liquid code snippet that calculates total inventory across variants and displays “In stock: X items” or “Out of stock” messages.
-
ProtoMan44 provides an alternative, simpler code snippet to display stock quantity directly on the product page by looping through product variants.
Note: The code snippets in the original posts appear reversed/garbled in formatting, but both responses aim to help implement inventory display through Liquid template modifications.
The discussion remains open with no confirmation from the original poster on whether either solution resolved their issue.
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 %}