Solved

Show text when specific size reaches 0 quantity

analgiev
Tourist
12 0 1

Hello Shopify Experts,

I have two sizes for each product. XL and XL to 3XL.

I added them both as option sizes in the product info.

I would like to show the text ('this item is out of stock but available for preorder') in product information when the specific size reaches 0 in quantity.

Note: I want to sell the product even when out of stock but show this text when it reaches 0

Thank you so much for help!

 

Accepted Solution (1)
JustasG
Shopify Partner
13 2 1

This is an accepted solution.

This is a complex question and implementing this functionality requires very deep knowledge. I have came up with a hackish solution, that works in similar way, but has many limitations and should only be used if nobody comes up with a better idea.

 

If you have two sizes for all products and they're in exact order as you've described, you can display a static message. It will be one of these messages, based on product variant quantities left:

 

XL size is out of stock but available for preorder

XL to 3XL size is out of stock but available for preorder

XL and XL to 3XL sizes are out of stock but available for preorder

 

To add this functionality you must have inventory tracking and selling when out of stock for your products enabled. 

 

Go to Online Store -> Themes -> Customise
Select your product page template and add liquid block in Product information. Copy and paste following code:

 

{% if product.variants.first.inventory_quantity == 0 and product.variants.last.inventory_quantity > 0 %}
<p>XL size is out of stock but available for preorder</p>
{% elsif product.variants.first.inventory_quantity > 0 and product.variants.last.inventory_quantity == 0 %}
<p>XL to 3XL size is out of stock but available for preorder</p>
{% elsif product.variants.first.inventory_quantity == 0 and product.variants.last.inventory_quantity == 0 %}
<p>XL and XL to 3XL sizes are out of stock but available for preorder</p>
    {% endif %}

 

custom-liquid-block.jpg

 

 

 

 

Limitations:

  • functionality breaks if there are more than 2 variants.
  • functionality breaks if there are more than 2 sizes in the store.
  • if there are products with just 1 variant you might need to create and adjust different product template for them.
  • message is static and does not change dynamically depending on chosen variant.

 

Due to the limitations I strongly advise using this method only if you can't find a better solution.

View solution in original post

Replies 4 (4)

JustasG
Shopify Partner
13 2 1

Hello, Analgiev,

Functionality to display a message when a product variation reaches 0 in quantity can be done with editing theme code. I'm ready to help you, but first I need more information. Could you please tell what theme you are using and your Shopify store URL?

 

Best Regards,
Justtas G.

analgiev
Tourist
12 0 1

Hi Justas,

Thanks for getting back!

I'm using the Dawn theme, however, the store is in production now I'm building it.

JustasG
Shopify Partner
13 2 1

This is an accepted solution.

This is a complex question and implementing this functionality requires very deep knowledge. I have came up with a hackish solution, that works in similar way, but has many limitations and should only be used if nobody comes up with a better idea.

 

If you have two sizes for all products and they're in exact order as you've described, you can display a static message. It will be one of these messages, based on product variant quantities left:

 

XL size is out of stock but available for preorder

XL to 3XL size is out of stock but available for preorder

XL and XL to 3XL sizes are out of stock but available for preorder

 

To add this functionality you must have inventory tracking and selling when out of stock for your products enabled. 

 

Go to Online Store -> Themes -> Customise
Select your product page template and add liquid block in Product information. Copy and paste following code:

 

{% if product.variants.first.inventory_quantity == 0 and product.variants.last.inventory_quantity > 0 %}
<p>XL size is out of stock but available for preorder</p>
{% elsif product.variants.first.inventory_quantity > 0 and product.variants.last.inventory_quantity == 0 %}
<p>XL to 3XL size is out of stock but available for preorder</p>
{% elsif product.variants.first.inventory_quantity == 0 and product.variants.last.inventory_quantity == 0 %}
<p>XL and XL to 3XL sizes are out of stock but available for preorder</p>
    {% endif %}

 

custom-liquid-block.jpg

 

 

 

 

Limitations:

  • functionality breaks if there are more than 2 variants.
  • functionality breaks if there are more than 2 sizes in the store.
  • if there are products with just 1 variant you might need to create and adjust different product template for them.
  • message is static and does not change dynamically depending on chosen variant.

 

Due to the limitations I strongly advise using this method only if you can't find a better solution.

analgiev
Tourist
12 0 1

I like your solution @JustasG.

Thanks for letting me know about the limitations.

I was really looking to display it dynamically. But it seems complex.