All things Shopify and commerce
Hi,
I'd like to limit the total number of sales of a limited edition piece of clothing. We'll only have one product live at a time. I need to use variants as customers will need to be able to choose their size. I've been trying to use Flow to check total number of orders when an order is created and if the threshold is reached, set all variants to zero inventory, but I can't seem to work it out. Is it even possible with Flow? Thanks
Instead of setting the variants to zero inventory, why don’t you just remove the product from the online store sales channel?
Oh, maybe you want to still show the product on your website as sold out?
I haven’t really checked if flow has an action like that but you could have your dev cook up a small server listening to the order created webhook and setting inventory to 0 through a GraphQl mutation.
Thanks for your suggestion. I don't mind what method I use to remove the product from sale (e.g., zeroed inventory or removal), but I need it to be automated so I don't have to manually monitor it 24/7 🙂
Hello @pmruk,
You can absolutely do this with Flow (you just need Shopify Plus to run it). The trick is to keep a running tally in a product‑level metafield, then zero out all variants when you hit your cap. Here’s the high‑level setup:
1. Create two product metafields
limit_total_sales (type: number) → set it to your max (e.g. 100)
total_sales (type: number) → defaults to 0
2. Build a Flow
- Trigger: Order created
- Actions:
1/ Loop through each line item in the order
2/ If line_item.product.id equals your limited‑edition product’s ID:
-> Increment product.metafields.total_sales by line_item.quantity
3/ After the loop, If product.metafields.total_sales >= product.metafields.limit_total_sales:
-> Loop through product.variants
-> Set inventory level (at your fulfillment location) to 0 for each variant
That last step will effectively sell out all sizes at once the moment your cap is reached. From then on, all variants show “Sold out.”
If you’re not on Plus or want something quicker, there are “order‑limit” apps in the App Store that handle global caps for you—but Flow gives you total control without another subscription.
This is great, thank you. I've managed to loop through the order line items but I can't work out how to increment the value of `total_sales`. I get an invalid or unknown tag error every time.
Unfortunately, Shopify Flow doesn't have a built-in trigger to track the total number of sales for a specific product or variant and adjust inventory based on a threshold. However, you can achieve this with a combination of apps like Shopify's Inventory & Product Bulk Editor or Stocky (for managing inventory thresholds), or by using custom scripts through Shopify Plus. For non-Plus stores, consider using a third-party app that integrates with Flow to monitor sales and automatically adjust inventory when the sales threshold is reached.
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025