MJH1
1
Hello:
I’m creating a new online store using the Blockshop theme, and have separate, product-specific versions of the product.json product template.
I want to have the product inventory amount be displayed on each specific product page.
What would be the code to allow this, and where would it be inserted into the code for the product.json product template?
I’ve seen this query be answered for other themes, but not for Blockshop.
Any assistance is greatly appreciated.
1 Like
@MJH1
{% 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 %}
There are **{{ product_qty }}** units left in stock.
{% endif %}
Try out this code and add it on your product.liquid or product-template.liquid file
@MJH1
Let me know if you need. any more help.
Thank you.
MJH1
4
Thanks for providing the coding, Mr_RaviRaj.
My next question is where in the product.liquid or product-template.liquid file for the blockshop theme, would it be placed?
For my original query, I’ve seen placement after line 111 or about that position, be indicated for other themes, but not for blockshop.