Shopify themes, liquid, logos, and UX
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.
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 %}
<p>In Stock</p>
{% endif %}
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
Please share your Sections/product-template.liquid file code .
Thanks!
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 %}
<div id="variant-inventory" class="{% unless current_variant.available %} hide {% endunless %}">
{% 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 %}
</div>
"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 %}
<div id="variant-inventory" class="{% unless current_variant.available %} hide {% endunless %}"> {% 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 %} </div>
or alternatively you can only check for inventory_quantity > 0
<div id="xyz" class="{% unless current_variant.available %} hide {% endunless %}">
{% if current_variant.inventory_quantity > 0 or current_variant.inventory_policy != "continue" %}
<span class="in-stock"> In stock</span>
{% endif %}
</div>
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)
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024