Display as out-of-stock when inventory >0

Topic summary

Goal: Show product variants as “Out of stock” on the storefront when inventory falls below a per-variant buffer stored in a metafield, without changing actual inventory or hiding products.

Proposed approach: Use Shopify Liquid (theme templating) to conditionally hide the Add to Cart button and display an “Out of stock” message when variant.inventory_quantity is below a threshold. Example shared uses a hardcoded threshold (e.g., 10) and suggests placing the logic where the add-to-cart is rendered (often product-form.liquid) and styling via a CSS class.

Implementation notes:

  • If multiple variants exist, iterate through variants or ensure the logic targets the selected variant.
  • Liquid docs were referenced for relevant variables.
  • Work on a duplicated theme to avoid impacting the live site.

Open items / limitations:

  • The provided snippet uses a fixed number; it does not yet read the per-variant metafield (custom field) to set the buffer dynamically.
  • No final code for metafield-based comparison was provided. Discussion remains open.
Summarized with AI on December 24. AI used: gpt-5.

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 %}

Out of stock

{% 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.