Auto-hide out-of-stock WooCommerce products with n8n and you stop losing sales to dead-end product pages. This guide builds a small workflow that scans your catalog on a schedule, moves any sold-out product to draft so it disappears from the storefront, and then quietly re-publishes it the moment stock comes back. No plugin subscription, no manual list to maintain, and a safety flag so it never touches drafts you created yourself.
What it does
A shopper who lands on a permanently sold-out product is a shopper who leaves. The default WooCommerce behavior keeps that page live, indexed, and clickable, showing an “out of stock” notice that reads like a closed door. This workflow closes the loop automatically.
On a schedule you control, it asks WooCommerce two questions: which published products are out of stock, and which of the products I previously hid are back in stock. Sold-out products get set to draft so they vanish from collections, search, and Google’s next crawl. Restocked products that the workflow hid earlier get flipped back to publish. Everything else is left alone.
The result is a storefront that only ever shows things a customer can actually buy, kept in sync without anyone remembering to check.
Why it beats the default
WooCommerce can show a “sold out” badge, but it will not remove the product from the catalog for you, and the free core has no built-in “hide when out of stock, show when restocked” toggle. The common alternatives each have a catch:
- Manually setting products to draft works until you have more than a handful of SKUs, then it becomes a chore you forget.
- A dedicated hide-out-of-stock plugin adds another paid subscription and another thing to keep updated, for one narrow job.
- Catalog visibility filters hide products from some views but often leave the direct URL live and indexable.
An n8n workflow owns the whole rule in one place: hide on sell-out, restore on restock, and never re-publish a product you deliberately left as a draft. You can read every step, change the schedule, or extend it later. If you run Shopify instead of WooCommerce, the same pattern is covered in our Shopify auto-hide out-of-stock guide, and the broader n8n Shopify automation hub lists the rest of the store workflows you can wire up the same way.
What you need
- A running n8n instance (self-hosted free edition or any n8n Cloud plan).
- A WooCommerce store on WordPress with the REST API enabled (it is on by default).
- A WooCommerce API key pair (Consumer Key and Consumer Secret) with Read/Write access. If you have not connected WooCommerce to n8n before, our WooCommerce to n8n guide walks through generating that key.
- About 20 minutes to build from scratch, or a couple of minutes if you import the template below.
Node-by-node list
The whole thing is five core nodes, no AI and no paid add-ons:
- Every hour — Schedule Trigger. Fires the scan on an interval you set.
- Get out-of-stock live products — HTTP Request (GET). Pulls published products whose
stock_statusisoutofstock. - Get hidden back-in-stock products — HTTP Request (GET). Pulls draft products that are back
instock. - Decide hide or restore — Code node. Tags each product with the action to take and builds the update body, using a meta flag as a safety gate.
- Update product visibility — HTTP Request (PUT). Writes the new status back to WooCommerce, one product per item.
┌───────────────────────────────────────────────────────────────┐ │ AUTO-HIDE OUT-OF-STOCK WOOCOMMERCE PRODUCTS │ │ │ │ [Every hour] │ │ ├──> [Get out-of-stock live products] ─┐ │ │ └──> [Get hidden back-in-stock prods] ─┤ │ │ v │ │ [Decide hide or restore] │ │ v │ │ [Update product visibility] │ └───────────────────────────────────────────────────────────────┘
Step-by-step build
- Add a Schedule Trigger node, name it Every hour, and set the rule to an interval of
hourswith a value of1. - Add an HTTP Request node named Get out-of-stock live products. Set method to
GETand URL tohttps://YOUR_STORE.com/wp-json/wc/v3/products. Under Authentication choose Predefined Credential Type and pick WooCommerce API. Turn on Send Query Parameters and add three:status=publish,stock_status=outofstock, andper_page=100. - Duplicate that node, name the copy Get hidden back-in-stock products, and change the query parameters to
status=draft,stock_status=instock, andper_page=100. - Wire the Schedule Trigger to both HTTP GET nodes so they run in parallel on every fire.
- Add a Code node named Decide hide or restore and connect both GET nodes into it. Paste the logic below. It reads every incoming product, decides whether to hide or restore it, and builds the exact body WooCommerce needs.
const out = [];
for (const item of $input.all()) {
const p = item.json;
const meta = Array.isArray(p.meta_data) ? p.meta_data : [];
const flag = meta.find((m) => m.key === '_auto_hidden_oos');
if (p.status === 'publish' && p.stock_status === 'outofstock') {
out.push({ json: { id: p.id, name: p.name, action: 'hide',
body: { status: 'draft',
meta_data: [{ key: '_auto_hidden_oos', value: 'yes' }] } } });
} else if (p.status === 'draft' && p.stock_status === 'instock'
&& flag && flag.value === 'yes') {
out.push({ json: { id: p.id, name: p.name, action: 'restore',
body: { status: 'publish',
meta_data: [{ key: '_auto_hidden_oos', value: '' }] } } });
}
}
return out;
- Add a final HTTP Request node named Update product visibility. Set method to
PUTand URL tohttps://YOUR_STORE.com/wp-json/wc/v3/products/{{ $json.id }}. Use the same WooCommerce API credential. Turn on Send Body, set Body Content Type to JSON, and set the JSON body to the expression{{ JSON.stringify($json.body) }}. - Connect Decide hide or restore into it. Because the Code node emits one item per product, this node runs once per product and updates each independently.
- Save, then click Execute Workflow to run a manual test. Check a sold-out product in wp-admin: its status should now read Draft. Restock it, run again, and confirm it flips back to Published.
- When it behaves, toggle the workflow Active so the schedule takes over.
Tip: The _auto_hidden_oos meta flag is the whole safety story. Only products the workflow itself hid carry it, so a product you left as a draft on purpose is never auto-published when it happens to be in stock.
Common mistakes
- Read-only API keys. The PUT step needs Read/Write. A key created with Read access returns a 401 on update while the GET steps still work, which makes the failure look mysterious. Regenerate the key with Read/Write.
- A trailing slash or wrong protocol in the store URL. Use
https://yourstore.com/wp-json/wc/v3/productswith no trailing slash and make sure the site is on HTTPS, or WooCommerce rejects the signed request. - Forgetting pagination on large catalogs.
per_page=100handles one page. If you routinely have more than 100 out-of-stock products at once, add a loop that increments thepageparameter until the response comes back empty. - Restoring by stock alone. If you drop the meta-flag check and re-publish every in-stock draft, you will push half-finished products live. Keep the
flag.value === 'yes'condition. - Running the scan too often. Every minute is wasteful and hammers your store. Hourly is plenty for almost everyone.
Cost at realistic volume
This workflow is effectively free to run. It uses only core n8n nodes, so there is no AI token spend and no premium node requirement.
| Component | Plan | Cost |
|---|---|---|
| n8n (self-hosted) | Community edition | $0 |
| n8n Cloud (optional) | Starter | From about $24/mo, covers this and dozens of other flows |
| WooCommerce REST API | Included with your store | $0 |
| Executions | Hourly scan = ~720/mo | Well inside free/starter limits |
An hourly run is roughly 720 executions a month, each a couple of quick API calls. On self-hosted n8n that is zero marginal cost; on Cloud it is a rounding error against your plan’s included executions.
🚀 Ready-to-import template
The guide above is free to follow. If you would rather skip the build, download the validated workflow JSON, import it into n8n, add your WooCommerce key, and go live in a couple of minutes. Prefer it done for you end to end? Our done-for-you service installs and tests it on your instance.
Instant download · Works on n8n Cloud and self-hosted
FAQ
Does this delete my out-of-stock WooCommerce products?
No. It changes a product’s status from publish to draft, which removes it from the storefront but keeps every field, image, review, and URL intact. When stock returns, the workflow flips the same product back to publish. Nothing is ever deleted.
How does it avoid re-publishing a draft I created on purpose?
When the workflow hides a product it writes a meta flag named _auto_hidden_oos = yes. The restore branch only re-publishes drafts that carry that flag and are back in stock, so half-finished products you left as drafts are never touched.
How often should the scan run?
Hourly is a good default for most stores and stays well inside free-tier limits. High-velocity stores can drop the Schedule Trigger to every 15 minutes; slow-moving catalogs can run it once or twice a day. Change the interval on the single trigger node.
Will this work on WooCommerce with variable products?
The workflow acts on the parent product’s stock_status. If you manage stock at the variation level, a parent shows outofstock only when every variation is sold out, which is usually the behavior you want. To hide individual variations you would extend the workflow to loop through the variations endpoint.
Do I need a paid n8n plan for this?
No. The workflow uses only core nodes (Schedule Trigger, HTTP Request, Code) that run on the free self-hosted edition and on the lowest n8n Cloud tier. The only external cost is your existing WooCommerce store, so at realistic volume this runs at zero added cost.