Shopify themes, liquid, logos, and UX
Hi everyone,
I'm trying to display "In stock" and "Out of stock" on my product page with custom liquid. So when a customer selects a variant inside the product, it checks if the variant is in stock or not, and shows the relevant text. I have tried this, but it doesn't work, any ideas?
{% if variant.inventory_quantity < 1 %}
<p>In stock </p>
{% else %}
<p>Out of stock </p>
{% endif %}
Anyone knows what i do wrong?
Hi @Hannibal_Herman ,
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>
{% else %}
<p>Out of stock</p>
{% endif %}
Hi Smalltask,
Thanks for the response, but it doesn't work. ;(
You can still buy if it's out of stock, so everyone is available. Is there a way so if there is min 1 in stock it says "in stock" and if there is 0 it says "Out of stock"?
try same thing but
{%- if variant.available == false %} - out of stock {% endif %}
Doesn't work ;/
you are most likely pasting the code into the wrong place then a good way to check is same code but put <h1> testing</h1> see where it shows up
I'm pasting the code correctly, just tried the <h1> testing</h1> and it shows up the right place.
But if i copy this code =
{%- if variant.available == false %} - out of stock {% endif %}
Nothing shows up ;/
My website is www.rios1931.dk
The problem might be in the way of implementation. You change your variant without page reload, because it's dynamic and liquid code is not updated. It should be done with JavaScript, not Liquid.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025