Limit total sales across variants

Limit total sales across variants

pmruk
Visitor
3 0 0

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

Replies 5 (5)

Malik_
Shopify Partner
8 0 3

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.

pmruk
Visitor
3 0 0

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 🙂 

Kudosi-Carlos
Excursionist
121 8 38

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.

- Was my answer helpful? Please hit Like or Mark it as solution!
- Kudosi Product Reviews - The must-have Shopify app that empowers you to effortlessly collect, display, and manage product reviews.
- Start your FREE trial today!
pmruk
Visitor
3 0 0

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.

 

Screenshot 2025-04-17 at 09.39.30.png

richardcobain
Pathfinder
140 5 17

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.