Theme Stack Guide
Choose, customize, and get the most from Shopify themes

How do you add a low-stock indicator to a Shopify product page?

Your theme already has the inventory number in Liquid. Show a low-stock message when quantity drops below a threshold, update it when the shopper switches variants with a few lines of JavaScript, and keep the threshold honest so the urgency stays believable.

Low-stock indicators work because they resolve hesitation, not because they trick anyone. A shopper deciding between your store and a competitor will often buy now if they believe the item might sell out. The inventory data is already available in your theme through Liquid, so you can build this without an app in under an hour.

Method 1: a Liquid threshold check

The simplest version is a conditional in your product template. Shopify exposes variant.inventory_quantity in Liquid. Wrap a message in a check like: only render when the quantity is above zero and below your threshold, say five units. Place it directly under the variant picker and above the add-to-cart button, where the shopper is already looking.

The threshold matters. Show the message at twenty units and shoppers learn to ignore it. Show it at three or fewer and it reads as genuine. Pick a number that reflects how fast the product actually sells. For a product that moves two units a day, a threshold of five is honest. For one that moves two units a month, it is theater, and shoppers can tell.

Method 2: make it variant-aware

The Liquid-only version has a flaw: it renders for the default variant. When the shopper switches from Small to Medium, the message does not update unless you add JavaScript. The fix is small. Give the message element an ID, listen for the variant change event your theme already fires, and update the text from the new variant's inventory quantity, which most themes expose in a JSON object on the page.

If the selected variant is out of stock or above the threshold, hide the message entirely. An indicator that says “only 2 left” for a variant with two hundred units in stock is worse than no indicator at all, because it trains shoppers to distrust everything else on the page.

Method 3: show it in the cart drawer

A quieter option is to surface low stock in the cart drawer or on the cart page instead of the product page. This keeps the product page clean while still creating urgency at the moment of commitment. The same Liquid check works in cart line-item templates, comparing each line item's variant quantity against your threshold.

Accuracy rules that keep it honest

Only show real numbers from your actual inventory. Do not hard-code “only 3 left” as static text, and do not show the indicator when inventory tracking is disabled for the product, because then the number is meaningless. If you use multiple locations, decide which location's quantity the message reflects and be consistent.

Also consider hiding exact numbers and showing a softer message like “low stock, order soon” if your inventory syncs from a warehouse with a delay. A precise number that turns out to be wrong erodes more trust than a vague one.

Testing before you publish

Duplicate your theme and test every path: a product below the threshold, one above it, one with tracking off, and each variant of a multi-variant product. Switch variants on mobile and confirm the message updates or hides correctly. Check that the message does not appear for products where you show inventory as unavailable rather than countable.

Where to put the code

In most themes, the product form lives in a snippet like product-form.liquid or in the main product section file. Add your Liquid conditional just above the add-to-cart button markup so the message sits where the eye already is. Keep the markup simple: a paragraph or div with a class you can style, and an ID your JavaScript can target for variant updates.

Style it to match your theme rather than shouting. A small line of text in your theme's accent color, or with a subtle dot indicator, reads as information. A flashing red banner reads as pressure, and pressure is what makes shoppers suspicious. The goal is a nudge, not an alarm.

Edge cases worth handling

Products with inventory tracking turned off should never show the message, because there is no real number behind it. Check variant.inventory_management in your conditional and skip the message when it is blank. Products that allow overselling, where the quantity can go negative, need the check to require a positive quantity too.

If you sell in multiple markets with different inventory, decide which pool the message reflects and document the choice. Shoppers in one region seeing a low-stock warning based on another region's numbers will eventually notice, and the explanation is awkward.

Will a low-stock indicator hurt trust if the number is wrong?
Yes, which is why it must read live inventory data. A wrong number teaches shoppers that your urgency messages are decorative, and that lesson transfers to your sale banners and shipping promises.
What threshold should you use?
Low enough to be believable for that product's sales velocity, usually three to five units. The right number is the one where the product genuinely might sell out before restock.

Frequently asked questions

Where is the best place for a size chart link?

Directly beside the size selector on the product page, opening in a popup or drawer so the shopper does not lose their place.

Should size charts show inches or centimeters?

Both. International shoppers are a large share of online apparel traffic, and conversion between units is where mistakes happen.

Can I show a different chart per product?

Yes, with product metafields or a size chart app. That is the right route when sizing varies by brand or category.