Display low inventory on product pages

contactdaiquiri
Pathfinder
91 0 19

Hi,

I would like to display a message when the selected variant has ❤️ units in stock. 

I was given this code - added on a custom liquid section on product pages - but it does not work (nothing is happening). Any other idea ? Thank you ! 

 

{% if product.variants.first.inventory_quantity < 5 and product.variants.first.inventory_quantity > 0 %}
  <p style="color: #D0DF00; text-align:center">ONLY {{ product.variants.first.inventory_quantity }} LEFT</p>
{% elsif product.variants.first.inventory_quantity < 1 %}
<p style="color: #D0DF00; text-align:center">SOLD OUT</p>
{% endif %}
Reply 1 (1)

Lana
Shopify Staff (Retired)
849 77 107

Hello, @contactdaiquiri!

 

I wouldn't be able to advise on coding changes for this myself, however I can recommend some third party apps that can help you seamlessly include this feature in your online store:

 

 

Make sure to have a look through each of these options to see which one will suit you best. You will see here that some of them have free plans available, but it's still good to look through the features of the ones on the paid plans also in case there is something there that you feel would benefit your store. 

 

If you're not happy with the option of adding an app for this feature, there is also an option to look into a custom solution here through hiring a Shopify expert as seen in this link here

 

They charge their rates based on the work that they do, but you may end up with a more tailored solution than an app, and it would be a once off fee for the job they do, rather than recurring app fees.

 

I also just wanted to add a tip here - if you do wish to go down the route of changing the code of your theme to achieve this, I would recommend that you duplicate the theme by following these steps here.

 

This way, should anything go wrong, you will have an untouched copy of your theme that you can always go back to.

Lana | Social Care @ Shopify
-Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog