Templates

Out-of-stock auto-hide

Automation template · Catalog ·View source

Sign in to use

When a product sells out, hides it from the store or marks it as on backorder, and puts it back as soon as stock returns. Only products it hid itself are restored.

How it works

Trigger
A product's stock changes
Sold out
Hides the product, or marks it as on backorder, when its stock reaches 0
Back in stock
Restores the products it hid, as soon as stock is above 0 again
Runs on its own
No approval step; it changes one field and nothing else
Optional
Posts each change to a Slack channel

What it needs

From your data. The agent finds the matching fields in your schema and confirms them with you.

  • The product or variant's name
  • The quantity on hand
  • The field that controls whether customers can see or buy the product: a published flag, a status, or an availability value such as in stock / backorder
  • The SKU, for the Slack message (optional)
  • A per-product flag for products that may keep selling at 0 stock (optional)

You'll choose

  • When a product sells out · default hideHide it from the store, or keep it visible as on backorder
  • Value that hides the product · default unpublishedWhat the availability field is set to when a product sells out, e.g. unpublished, draft, false or backorder
  • Slack channelOptional; where hidden and restored products are posted

Example output

Run summary

2 changes: Linen Shirt, Sand, M (LS-SND-M): hidden (stock 1 → 0) Ceramic Pour-Over Set (CPO-WHT): back on sale (stock 0 → 24)

Back in stock but hidden by someone else: Beeswax Candle, Large (BWC-L). Left as it is.


Slack, #ops-inventory

Sold out and hidden: Linen Shirt, Sand, M (LS-SND-M) Back on sale: Ceramic Pour-Over Set (CPO-WHT)

Show the instructions

Out-of-stock auto-hide

One or more products were just updated. For each one whose stock crossed zero, change its availability, and change nothing else. Many updates have nothing to do with stock; most runs should end without a change.

1. Find the products that crossed zero

The trigger gives each updated product’s values before (old) and after (new) the change. For each product:

  • Sold out: stock was above 0 before and is 0 or below now.
  • Back in stock: stock was 0 or below before and is above 0 now.
  • Anything else (stock unchanged, or still above 0, or still at 0) is not your concern: skip the product.

Also skip a product that:

  • has backorders allowed on the record, when the store keeps such a flag;
  • is archived, discontinued or a draft that was never published;
  • would already be in the target state (it is already hidden when sold out, or already visible when back in stock). Never write a value the field already has.

If no product is left, end the run as skipped (Finish Run with status skipped).

2. Sold out

Set the availability field to {{hiddenValue}} ({{action}}). Write that one field only; do not touch price, stock, name or anything else.

Record the product’s id and its previous availability value in your automation memory under “hidden by this automation”, so you restore exactly what you hid.

3. Back in stock

Restore a product only if it is in your “hidden by this automation” list. Set the availability field back to the previous value you recorded, then remove the product from the list.

A product that someone else hid (a person, or another automation) stays as it is, even with stock: they may have hidden it for another reason. Mention it in the run summary: “Back in stock but hidden by someone else: Linen Shirt, Sand, M”.

4. Report

  • Summarise each change on one line: name (SKU), “hidden” or “back on sale”.
  • If a Slack channel is set ({{channel}}), stage one short message with the same lines. If it is empty, skip Slack.
  • If a write fails, flag the run with the product and the error. Do not retry in a loop.

Your own writes do not start this automation again, so you do not need to guard against that; still, never write a value that is already set.