Tags active products that have any variant missing its unit cost with 'needs-cost' and removes the tag once every variant has a cost.
async def run(ctx): for product in await ctx.shopify.query(ACTIVE_PRODUCTS): missing = any(v.unit_cost is None for v in product.variants)
How do you find products missing cost of goods on Shopify?
To find products missing cost of goods on Shopify, this template scans every active product and tags the ones where any variant has no unit cost, then removes the tag once every variant carries one. It checks the cost per item field on each variant individually, because one costed variant on a product with nine empty ones still breaks every margin number downstream. It is the prerequisite for every margin check in this gallery: profit math over incomplete costs produces confident nonsense.
Hunting missing costs by hand means exporting the catalog and filtering an empty column the admin never surfaces. Here the first run is the deliverable itself: a complete list of products that need a cost, produced without writing anything. Tag them after approval, hand the list to whoever owns supplier data, and re-run until it comes back empty.
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