Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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!
Solved! Go to the solution
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 %}
Limitations:
Due to the limitations I strongly advise using this method only if you can't find a better solution.
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.
Hi Justas,
Thanks for getting back!
I'm using the Dawn theme, however, the store is in production now I'm building it.
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 %}
Limitations:
Due to the limitations I strongly advise using this method only if you can't find a better solution.
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.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024