Display inventory messages on variants

New Member
1 0 0

I'm newish to Shopify and definitely new to liquid, although I know how to code basic html.

 

I am trying to add a display message when inventory <=0 but is set to allow orders. I found a bit of code (below) and managed to get it in the right place to work on items that don't have variants, but on variants it still allows orders but with no message.  Is there something I can add to this to have it work on the variants also?  Thanks!

 

{% if product.variants.first.inventory_management == "shopify" and product.variants.first.inventory_quantity > 0 %}

{% endif %}

{% if product.variants.first.inventory_management == "shopify" and product.variants.first.inventory_quantity <= 0 %}

        This items is custom made and will ship in 5 business days.

 {% endif %}

0 Likes
Highlighted
Shopify Partner
6 0 0

Hi there,

 

Adan here from Askadan

 

I know what you need done and have had experience with doing that exact task :)

 

If you would like, please feel free to contact me via email and I can help you out the same day (24 hours) as your response!

 

Email: info@askadan.com

 

Thanks for your time, and have an awesome day!

0 Likes
Shopify Partner
133 4 14

If you are not doing anything with that first block, you could simply delete it.. so this one:

 

{% if product.variants.first.inventory_management == "shopify" and product.variants.first.inventory_quantity > 0 %}

{% endif %}

You are not outputting anything, so it could be removed

 

{% if product.variants.first.inventory_management == "shopify" and product.variants.first.inventory_quantity <= 0 %}

        This items is custom made and will ship in 5 business days.

 {% endif %}

This seems to check the product's first variant for inventory, is this what you want? or could it be that sometimes the first variant has inventory and the second variant hasn't and that's why it looks like it isnt working.

0 Likes