Hello,
I would like to be able to display “In Stock” label on the product page for customers to see when they view a product that is in stock. I am using the "Supply" theme. Google merchant center requires that display function now.
Currently, the theme only displays a “sold out” label for products that are out of stock on the individual product pages.
How would I go about doing this?
Thank you.
@magicwheels
Please Go to Online Store → Themes → Edit code → Sections → product-template.liquid and paste this code whereever you want to set.
{% if product.selected_or_first_available_variant.available == true %}
In Stock
{% endif %}
2 Likes
@magicwheels
Please Go to Online Store → Themes → Edit code → Sections → product-template.liquid and paste this code whereever you want to set.
{% comment %} Inventory tracking on product page {% endcomment %}
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %}
We have {{ current_variant.inventory_quantity }} in stock.
{% else %}
This product is available.
{% endif %}
1 Like
Thank you very much for help, I have pasted into the product-template.liquid section, but the “In Stock” sign didn’t show up, may be I pasted to wrong position? is there a specific line I should paste? thanks
@magicwheels
Please share your Sections/product-template.liquid file code .
Thanks!
2 Likes
“current_variant” variable needs to be defined like so :
{% assign current_variant = product.selected_or_first_available_variant %}
so the full code will be something like : =>
{% assign current_variant = product.selected_or_first_available_variant %}
{% if current_variant.inventory_management == "shopify" and current_variant.inventory_policy != "continue" %} We have {{ current_variant.inventory_quantity }} in stock. {% else %} This product is available. {% endif %}
or alternatively you can only check for inventory_quantity > 0
{% if current_variant.inventory_quantity > 0 or current_variant.inventory_policy != "continue" %}
In stock
{% endif %}
Hi All
So everyone here seems to be trying what I have just discovered
I please need help with my code, I cannot seem to get it right?
I also want labels that show something is in stock or out of stock? (and still continue to take orders from cleints)