Inventory & suppliers
Auto-hide sold-out products and republish on restock
A product that's sold out shouldn't keep taking clicks and ad spend to a dead 'sold out' button. Here's how to detect when a product is genuinely out across every variant, hide it from your storefront, and bring it back on its own the moment it restocks — without the listing flickering on and off during a busy sale.
- Shopify
- n8n
The manual way today
Someone notices a product is sold out — usually because a customer mentions it or a sale empties it — opens the product in Shopify, and sets it to draft or unpublishes it from the Online Store. Then, whenever a restock lands, someone has to remember which products got hidden, find them in the drafts, and flip each one back to active. The 'bring it back' half is the part that gets forgotten.
A sold-out product left live keeps catching clicks from search, email, and paid ads, and every one of them lands on a button that can't be pressed — spend and attention burned on something the customer can't buy. The flip side is worse: a restocked product left in draft is a product nobody can find, sitting invisible while you've already paid to restock it. The page exists, the inventory exists, and the two just aren't connected because the manual step never happened.
What running looks like
When a product's inventory hits zero across every sellable variant, Shopify hides it from the storefront on its own and tags it so the flow knows it was the one that hid it. When that same product restocks past a small buffer, it republishes itself and the tag comes off — usually within a minute of the inventory change, untouched. Products you manually drafted are never touched, and a listing that dips to zero for a moment mid-sale doesn't yo-yo.
01The build
How to build it
Decide your hide rule, your two thresholds, and your exclusions
Needs a humanPin down the policy before automating anything. What counts as 'out': every sellable variant at or below zero across the locations that actually fulfill online orders, and the variant's inventory policy set to 'deny' (not 'continue', which means you're overselling on purpose). Set two numbers, not one: hide at 0, republish only at a small buffer (say 3) so one stray unit doesn't relist a product. List what never auto-hides — made-to-order SKUs, preorders, continue-selling items, and anything you tag 'always-live'. And decide hide-vs-keep per collection: for a hero product with ranking and backlinks, you may prefer keeping the page up with a back-in-stock signup instead of hiding it.
Catch Shopify's inventory-level webhook in n8n
Runs itselfSubscribe to the inventory_levels/update webhook and point it at an n8n webhook node. The payload is lean — it carries inventory_item_id, location_id, and the new available quantity, not the product. That's fine; the next step resolves it. This single topic fires for both directions: a sale that drains stock and a restock that refills it, so one trigger drives both the hide and the republish.
Resolve the inventory item to its product and read every variant
Runs itselfThe webhook only gives you an inventory_item_id, so look up what it belongs to. Use Shopify's GraphQL inventoryItem query to walk inventoryItem → variant → product, then pull the product's full variant list with each variant's inventoryPolicy and its available quantity per location (quantities(names: ["available"]) on each inventory level). You need the whole product's picture, not just the one variant that changed — hiding on a single sold-out size when other sizes are in stock is exactly the mistake to avoid.
Decide whether the product is genuinely out
Runs itselfHide only when every sellable variant is at or below zero across the fulfilling locations and its inventory policy is 'deny'. Sum available across those locations per variant — and ignore a damages, quarantine, or staff location that never ships to customers, or you'll keep a product live on stock no online order can ever pull from. Then apply the exclusions from step one: skip continue-selling, preorder, made-to-order, and always-live products. If even one variant can still be bought, the product stays live.
Hide it and stamp it with a tag
Runs itselfSet the product's status to DRAFT with the productUpdate mutation (or, if you want it gone from the Online Store but kept on POS and other channels, unpublish just that publication instead). In the same run, add a tag like auto-hidden-oos plus the date. That tag does two jobs: it's the idempotency key so a re-fired webhook won't act twice, and it's the marker that this flow — not a human — hid the product, which is what makes a safe automatic republish possible.
Republish only what the flow hid, when stock crosses the buffer
Runs itselfWhen an inventory_levels/update for a restock comes in, resolve it to the product as before and check two things: does it carry the auto-hidden-oos tag, and is total sellable inventory now at or above your republish buffer from step one? Only if both are true do you set status back to ACTIVE (or re-publish the Online Store publication) and remove the tag. Gating on the tag is what keeps the flow from ever un-hiding a product a person deliberately set to draft.
Add hysteresis so the listing doesn't flap during a sale
Runs itselfInventory near zero is noisy — a unit sells, a return restocks it, a count corrects — and a naive flow would hide and show the same product several times an hour. The gap between your two thresholds (hide at 0, republish at 3) already absorbs most of it. Add a short debounce on top: when a hide or republish would fire, wait a minute, re-read the product's current stock, and only act if it still qualifies. That turns a flurry of webhook events into one clean state change.
Reconcile on a schedule and flag the exceptions
Runs itselfWebhooks get dropped. Once a day, run an n8n schedule that pulls products carrying the auto-hidden-oos tag and confirms they're genuinely still out, and scans live products for any that are silently at zero. Fix the drift automatically where the rule is unambiguous, and post the genuine oddities — a product a human drafted that's now back in stock, a SKU whose locations don't add up — to wherever you watch ops, for a person to settle. The automation handles the rule; it never guesses on the edge cases.
02The stack
What it’s built on
- Shopify
- System of record for both the inventory and the listing. It emits the inventory_levels/update webhook, answers the variant-and-location lookup, and is where you flip product status to draft or active and write the auto-hidden-oos tag.
- n8n
- The glue: receives the inventory webhook, resolves it to the product, runs the out-of-stock and restock decisions with their thresholds and debounce, makes the hide/republish call, and runs the daily reconcile.n8n is open-source and self-hostable for free; their cloud tier just saves you running it yourself. Zapier can do the simple version, but the per-variant, multi-location logic and the debounce are far cleaner in n8n's code and branching nodes.
03Questions
Before you build
Does hiding a product hurt my SEO?
It can. A product URL that ranks or has backlinks loses that value while it's drafted or unpublished, and a returning crawler sees a missing page. For a long-tail product that's out for a day, the trade is fine. For a hero product with real ranking, the honest alternative is to keep the page live with a back-in-stock signup instead of hiding it — which is why step one has you decide hide-vs-keep per collection rather than applying one rule to everything.
Won't the listing flicker on and off during a busy sale?
Not with the two pieces in step seven. The gap between thresholds — hide at 0, republish only at your buffer — means a single unit trickling back in won't relist a product. On top of that, a one-minute debounce re-reads stock before acting, so a flurry of inventory events near zero collapses into one clean hide or one clean republish instead of a yo-yo.
Will it hide products I'm intentionally overselling or pre-ordering?
No. The decision checks each variant's inventory policy and skips anything set to 'continue' (your overselling and backorder products), plus anything tagged preorder, made-to-order, or always-live. A product that's meant to be buyable at zero stock stays live.
How does it handle inventory across multiple locations?
It sums available stock per variant across only the locations that actually fulfill online orders, so a product is hidden only when no online order could be filled. A damages, quarantine, or staff location is excluded — otherwise the flow would keep a product live on stock customers can never receive.
Will it un-hide a product I manually set to draft?
No, and that's deliberate. The flow only republishes products that carry the auto-hidden-oos tag it writes when it hides something. A product you drafted by hand has no such tag, so a restock leaves it exactly where you put it. The tag is the line between 'the automation hid this' and 'a person did'.
Can I build this myself, or should you build it?
Every trigger, field, and threshold is spelled out above, so if you've got API comfort and a few spare hours, wire it up yourself. If you'd rather not own the per-variant logic, the multi-location edge cases, and the debounce, we'll build it on the Shopify and n8n accounts you already pay for, document it, and hand you the keys — you own the workflow outright, with no monthly retainer. It starts with a free 20-minute teardown, not a contract.
Related recipes
Inventory & suppliers
Send low-stock Slack alerts from Shopify inventory
A bestseller running down to zero with nobody watching is the most avoidable stockout there is. Here's how to watch Shopify's live inventory and drop a clear, actionable alert in Slack the moment a SKU crosses its low-stock line — once per dip, not on every sale.
- Shopify
- Slack
Inventory & suppliers
Sync inventory between Shopify and a second sales channel
When you sell the same SKUs on Shopify and a second channel — Amazon, eBay, TikTok Shop, a wholesale store, a second Shopify — the stock counts drift apart the moment either one makes a sale. Here's how to keep both numbers honest from a single source of truth, decrement on every sale wherever it happens, and hold a safety buffer so the gap between 'sold' and 'synced' never turns into an oversell.
- Shopify
- n8n
Inventory & suppliers
Flag slow-moving inventory for clearance
Score every SKU by how many days of stock you're holding at its current sell rate, rank the slow movers by the cash they've tied up, and drop a ranked clearance list in a Google Sheet every week. You decide the lever — markdown, bundle, ad push, or discontinue — instead of discovering the problem at year-end inventory count.
- Shopify
- Google Sheets
Inventory & suppliers
Auto-generate purchase orders at the reorder point
Keep a reorder point and a supplier for every SKU in Airtable, read Shopify's live inventory on a schedule, and draft the purchase order automatically the moment stock drops to the line — then approve it before it sends. You reorder on lead time instead of finding out you're empty from a customer.
- Shopify
- Airtable
- n8n