Limit total sales across variants

Topic summary

A merchant wants to automatically stop sales of a limited-edition clothing item after a set number of total orders across all size variants. They initially attempted using Shopify Flow to monitor order counts and zero out inventory when the threshold is reached, but encountered implementation challenges.

Proposed solutions include:

  • Shopify Flow approach (requires Shopify Plus): Create two product metafields—one for the sales limit and one to track total sales. Build a Flow that triggers on order creation, loops through line items, increments the sales counter, and zeros all variant inventory when the cap is reached.

  • Custom webhook solution: Use a developer to create a server that listens to order-created webhooks and updates inventory via GraphQL mutations.

  • Third-party apps: Use order-limit apps from the Shopify App Store for simpler implementation without custom development.

Current blocker: The original poster successfully created the Flow loop but encounters “invalid or unknown tag” errors when attempting to increment the metafield value. One respondent notes Flow lacks native triggers for tracking total sales across variants, suggesting alternative tools or custom scripts may be necessary.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

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 :slightly_smiling_face:

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.