Shopify themes, liquid, logos, and UX
Hello,
We would like product variants to display as "Out of Stock" on our website when their inventory level drops below a certain number given by a variant metafield. This will give us a little buffer for fast-selling SKUs which might sell out before we can set aside the item for shipping/in-store pickup. We do not want to actually change the inventory level to 0 (as discussed in this post: https://community.shopify.com/c/shopify-discussions/can-you-automate-inventory-to-mark-items-as-out-...) or to hide/unpublish the product from our website; we just want it to look like the product is out-of-stock. Is this possible? I understand we will probably have to enter the code in our theme.
Thanks to everyone for the assistance.
I think you'd want to check the inventory of the variant, then if < a certain number, hide the add to cart button.
This will help to try variables:https://shopify.dev/docs/api/liquid/objects
I would try something like this:
{% if variant.inventory_quantity < 10 %}
<p class="out-of-stock">Out of stock</p>
{% else %}
Regular add to cart button here
{% endif %}
Try putting that where your add to cart button is (maybe in a snippet like product-form.liquid, you'll have to read the code in your theme files to see where).
If that doesn't work, then experiment with other relevant product and variant variables on that page, for example, if you have multiple variants for the product, you might have to cycle through them with a {% for %} loop. You can find all that in the Liquid documentation.
Once you get the code working, then create a CSS class out-of-stock to style it.
Duplicate your live theme first so you can work on a backup theme without affecting the live site.
Thank you Joe -- not quite as easy as I was hoping, but makes sense!
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025