Add ‘Only X Left’ Low Stock Warning to Shopify Products

The “Only 3 left in stock” message is one of the most powerful conversion tactics in e-commerce. It creates urgency based on real inventory data. Here’s how to add it to your Shopify store.

Why Low Stock Warnings Work

Scarcity is a fundamental psychological trigger. When customers see limited availability, they’re more likely to buy now rather than think about it later. This tactic is used by Amazon, ASOS, and virtually every high-converting e-commerce brand.

Method 1: Code It Into Your Theme (Free)

In your theme’s product template (main-product.liquid), add this snippet:

{% if product.selected_or_first_available_variant.inventory_management == "shopify" %}
  {% assign qty = product.selected_or_first_available_variant.inventory_quantity %}
  {% if qty > 0 and qty <= 10 %}
    <p class="low-stock-warning">Only {{ qty }} left in stock!</p>
  {% endif %}
{% endif %}

Method 2: Use a Scarcity App

  • Hextom: Inventory and Sold Count Bar — shows a visual inventory bar and sold count
  • Urgency Bear — countdown timers, stock countdowns, and social proof
  • Ultimate Sales Boost — comprehensive urgency toolkit including low stock badges

Method 3: Variant-Level Stock Warnings

Update the warning dynamically when a customer selects a different size or colour:

document.addEventListener("variant:change", function(e) {
  var qty = e.detail.variant.inventory_quantity;
  if (qty > 0 && qty <= 10) {
    document.getElementById("stock-warning").textContent = "Only " + qty + " left!";
    document.getElementById("stock-warning").style.display = "block";
  } else {
    document.getElementById("stock-warning").style.display = "none";
  }
});

When to Show the Warning

  • Show when quantity is 1-10 for most products
  • Show when quantity is 1-3 for high-priced or premium items
  • Never fake low stock — customers notice and trust is lost permanently
Previous Article

Add Custom Fields to Shopify Orders at Checkout

Next Article

Create Product Bundles on Shopify to Increase Average Order Value

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.

No spam, ever. Unsubscribe anytime.