Rounds each tracked variant's on-hand inventory up to the next multiple of a pack size (default 6) at every location, leaving zero-stock locations untouched.
async def run(ctx): pack = ctx.params.get("pack_size", 6) for level in await ctx.inventory.levels(): if level.available == 0:
How do you align Shopify inventory with pack sizes?
To align Shopify inventory with pack sizes, this template rounds each tracked variant's on-hand quantity up to the next multiple of your pack size, six by default, at every location, leaving zero-stock locations untouched. Warehouses that receive in cases but count in units drift into quantities that cannot physically exist on a shelf: 17 units of a product that only ships in sixes means someone miscounted, and the template's adjustment makes the drift visible instead of letting it accumulate.
Chasing those mismatches location by location is the kind of correction that gets done once during an audit and never again. As code, the rounding applies uniformly across every location and re-runs after each receiving cycle. The adjustment list, per variant per location, goes to whoever owns inventory before anything moves, so a real miscount becomes a recount, not a silent write.
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