Hi everyone,
I have displayed my stock count in my product cards in featured collection in my home using some codes that I inserted in my card-product.liquid file. Now, I wanted it to be displayed just like how it is displayed in my featured collection in homepage when I click one of my collection. See photo for reference:
This is what it looks like in my home page inside the featured collection section:
and I want it to be displayed here on the collection page too
Hello. @IntechCarl
The stock count may not be displaying on your Product Collection Page because the code covered only the Featured Collection and not your entire Collection Page.
To resolve this, locate the correct file for collection product cards.
It is usually one of these;
- collection-product-grid.liquid
- product-card-grid.liquid
- product-item.liquid
- card-product.liquid
then add this snippet to the product card loop:
{% if product.available %}
In stock ({{ product.variants.first.inventory_quantity }} left)
{% else %}
Out of stock
{% endif %}
Hi!, I have added the code in my card-product.liquid, but it is not showing in my collection pages
Hi @IntechCarl
You can try this code
{{ card_product.variants[0].inventory_quantity }}
Try this code then if your product has multiple variants;
{% if product.variants.size > 1 %}
{{ product.variants | map: ‘inventory_quantity’ | sum }} in stock
{% else %}
{{ product.variants.first.inventory_quantity }} in stock
{% endif %}
If the issue still persists, kindly share your store’s URL (with the password, if it is password enabled) for a tailored solution.