Stock quantities

sonnisaar
Visitor
2 0 0

Hi there, how can I display stock quantities on my website? Dawn version 14.

 

Replies 2 (2)

deservefirst
Shopify Partner
15 4 9

 

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 %}
  <p>In stock: {{ total_inventory }} items</p>
{% else %}
  <p>Out of stock</p>
{% endif %}
​

 

 

DeserveFirst | DeserveFirst.com

If my post is helpful, consider liking it -- it will help others with a similar problem to find a solution.

Stack: Shopify Plus | Shopify | NodeJs | ReactJs | NextJs | PHP | Magento | Laravel | WordPress | BigCommerce | Prestashop

Expertise: Shopify Plus | Headless CMS | PWA | App Development | Shopify Scripts | Shopify Functions & Extensions | Theme Development & Customization | New Feature Implementation

ProtoMan44
Shopify Partner
353 28 56

@sonnisaar hey,
 please use this code where you want to show on product page :

{% for variant in product.variants %}
<p> {{ variant.inventory_quantity }} in stock.</p>
{% endfor %}
- A thirsty developer passionate about supporting the community. If you'd like to, you can  

Buy me a Coffee.


- Your Shopify Solution Specialist Get a Quote at

ProtoMan44

 - 

Chat On Whatsapp


Crafting exceptional e-commerce experiences to elevate your online presence. Let's build your success story together!