Sets active products that have hit zero total inventory to DRAFT and tags them 'auto-hidden-oos', keeping sold-out items off the storefront without deleting anything.
async def run(ctx): for product in await ctx.shopify.query(ACTIVE_PRODUCTS): stock = sum(v.inventory for v in product.variants)
How do you hide out-of-stock products on Shopify automatically?
To hide out-of-stock products on Shopify automatically, this template sets active products to draft the moment total inventory hits zero and tags them auto-hidden-oos so the companion template can republish them when stock returns. Nothing is deleted: URLs, variants, images and history stay intact while sold-out items stop wasting storefront clicks and ad spend. Products you keep selling on backorder simply never hit zero available, so they never get touched.
Shopify can push sold-out items down inside collections, but the product pages stay live for search, feeds and direct links. Cleaning that up by hand means a weekly filter-and-draft session that nobody sustains past week three. Run on a schedule, each pass reports exactly which products it would hide; you approve, the storefront gets cleaner, and the recovery tag guarantees the way back. It also hands support an instant answer when a customer asks where a product went.
Last updated August 24, 2026
If you run a sharper version of this template, or something it inspired, send it in. We review every application and publish the good ones, credited to you or your agency.
AI writes real Python or TypeScript, a dry run rehearses it, you approve, it deploys.
Free plan · no card · 🇪🇺 EU data residency