Hi!
i just found this tutorial on youtube. credits to: https://speed-ecom.com/how-to-show-inventory-quantity-on-the-product-page-on-shopify/
I tried in on my custom porto theme and put the code in 2 files:
product_view_default-liquid <-standard product view
product.quickview.liquid <-quickview
but i modified it a bit to just test it in general
{% 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 %}>
The product is {{ product_qty }} x available!
{% endif %}
Since i am totaly clueless what happens in the script, would someone perhaps be so nice and tell if me if the stuff
written in there is correct and doing what it should be?. It seems to work exept with variants where it just adds all quantities together.
Can that be fixed perhaps that it only shows the quantity of the variant selected?
I tried this code alone before in my 2 liquid files:
We have {{ current_variant.inventory_quantity }} in stock.
But that only worked on the product quickview but not on the product page itself.
No idea why not
Please enlighten me!
Have a wonderful day!
Phil