When Dawn's Built-In Low-Stock Block Isn't Enough

When Dawn's Built-In Low-Stock Block Isn't Enough

If you've spent any time on Shopify forums you've seen this question. Someone asks how to show a "only 3 left" message on the product page. Five replies, five different apps suggested. Nobody mentions that Dawn already does this.

So this is about the part of the conversation that keeps getting skipped. Three tiers, in order: what Dawn gives you for free, where the built-in block stops being enough, and the snippet that covers most of what's left.

What Dawn already does

Open the customizer, find the product template, add an Inventory block to the product information section. There's a threshold setting and a few text style options. Below the threshold, a low-stock message shows up. Above it, nothing renders.

Under the hood Dawn reads product.selected_or_first_available_variant.inventory_quantity and re-renders the whole section when the customer switches variants. No JavaScript to write. No theme files to touch.

Quick test before going further: open a product page, pick a variant with two units in stock, and see if the message appears. If it does, you don't need the snippet below. You don't need an app either. The theme already solved your problem and you can close this tab.

Where the built-in block stops being enough

Four cases. They come up often enough that they're worth naming.

Tiered messaging. The built-in block has one threshold and one message. Only 5 left reads the same whether stock is at five or at one. Some stores want a softer note at ten, a sharper one at three, something different at zero.

Conditional logic. Maybe you only want low-stock on certain collections, or only above a certain price, or only for logged-in customers. The customizer has no surface for any of that.

Presentation. The default block inherits theme typography. Stores with a more designed product page often want the message somewhere else, styled differently, maybe with an icon next to it. Not configurable from the customizer.

Other surfaces. Collection cards, cart, quick-buy modals. The built-in block lives on the product template and stays there.

If none of those describe your store, stop here. The default block is doing its job.

{%- liquid
  assign variant = product.selected_or_first_available_variant
  assign stock = variant.inventory_quantity
  assign tracked = variant.inventory_management
-%}{%- if tracked == 'shopify' and variant.inventory_policy != 'continue' -%}
  {%- if stock <= 0 -%}
    <p class="stock-msg out">Sold out. Back in soon.</p>
  {%- elsif stock <= 3 -%}
    <p class="stock-msg critical">Only {{ stock }} left. Selling fast.</p>
  {%- elsif stock <= 10 -%}
    <p class="stock-msg low">Low stock. {{ stock }} remaining.</p>
  {%- endif -%}
{%- endif -%}

Eleven lines of substance. A few things going on that are worth flagging.

selected_or_first_available_variant is the right reference. Not variants.first, which is whichever variant got created first in the admin and has nothing to do with what your customer is actually looking at. On a single-variant product they're the same thing. On anything multi-variant, they're not.

The inventory_policy != 'continue' check is the one most snippets you'll find online forget about. Some stores keep selling after stock hits zero with backorders fulfilled later. Showing "sold out" on those products is wrong, because the product isn't sold out. If the policy is set to continue, the snippet stays quiet and lets the customer order.

You don't need JavaScript for the variant switch. As long as the snippet sits inside the main product section, Dawn re-renders the whole section when the customer picks a new variant, and your message updates with it.

Where to put it

In the customizer, add a Custom Liquid block to the product information section. Paste the snippet in. Drag it where you want, usually under the price or above add-to-cart. Then style the three CSS classes (out, critical, low) in your stylesheet so each tier has its own visual weight.

A note on doing it this way instead of editing main-product.liquid directly: customizer blocks survive theme updates. Theme file edits don't. Worth ten extra seconds.

When you actually need an app

There are real cases. Multi-location with location-specific messaging. Stock that needs to factor in incoming POs or scheduled restocks. A/B tests on urgency copy across customer segments. Geo-conditional messaging by country.

If your store is one of those, an app is the right answer and it's worth picking one carefully. Most stores aren't one of those. Most stores are choosing between the built-in block and a snippet, and the answer comes down to whether tiered messaging matters enough to justify eleven lines of code.

That's a more useful question than "which app should I install."


Pasilobus has been building Shopify apps and storefront engineering since 2014. If your low-stock problem is more complicated than the one in this post, tell us about it.

Retour au blog