Archives (reversibly) active products that have stayed at zero total inventory for N consecutive days (default 30), tracking dwell time in ctx.store.
async def run(ctx): limit = ctx.params.get("days", 30) seen = await ctx.store.get("oos_since", {}) for product in await ctx.shopify.query(ACTIVE_PRODUCTS):
How do you archive out-of-stock products on Shopify safely?
To archive out-of-stock products on Shopify safely, this template tracks how long each active product has sat at zero total inventory and archives the ones past your dwell threshold, 30 days by default. The dwell counter persists between runs, so nothing gets archived on a single bad snapshot the day after a stocktake glitch. Archiving is also reversible by design: the product leaves the admin's active list and the storefront but keeps its data, ready to restore when the supplier comes through.
Dead listings accumulate because deleting feels dangerous and reviewing hundreds of zombie products feels endless, so nobody does either. With dwell time computed for you, the decision shrinks to reading a list: every candidate with its days at zero, oldest first. Approve it and the catalog sheds its dead weight monthly instead of never.
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