Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi there,
I am trying to show stock availability on my product page when I add stock in the inventory for each variation. is there any code I can add, I seem to cannot find this feature.
Add this code into your product.template.liquid or main-product.liquid where you want to add
<!-- zworthkey-code -->
{% assign product_qty = 0 %}
{% for variant in product.variants %}
{% if variant.inventory_quantity > 0 %}
{% assign product_qty = product_qty | plus: variant.inventory_quantity %}
{% endif %}
{% endfor %}
{% if product_qty > 0 %}
<span class="products-available-container ws-widget" style=" height:25px;margin-bottom:30px;"><span class="products-available" style="color: white; margin-top:6px;"><p style="margin-top:6px;"><span> <span style="background-color: rgb(230, 0, 0); color: rgb(255, 255, 255); border-radius: 3px;"> HURRY! </span> Selling out fast! Only <strong style="color: rgb(230, 0, 0);"><span class="glowing odometer">{{ product_qty }}</span></strong> left in stock!</span></p>
</span>
{% endif %}
Let me know if you need any more help.
Thank you.
which line do i add it too? I have product-template.liquid section under Snippets and Sections
Thanks, Ravi.
Work well on Dawn Theme.
Hi there! I added this code and it is working but it shows the total quantity of a product. I do have product options in my store and want to display inventory quantities of the each product option separately. Is there a way to show product variant's quantity individually on the product page?
I just found this step by step guide that worked for me on where to add the liquid:
https://parasoul.co.uk/shopify/dawn-theme-display-inventory-quantity
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025