Control variant qty when it is updated based on custom conditions

You can set the logic to set variant quantity to 0 when the qty reaches some minimum threshold. This is useful when the products are sourced from some provider and the qty is set at certain interval. In such setup some time you end up overselling some products.

Context:

The merchant is sourcing items from someone and there is a backend job that sync the qty of all these items in Shopify. The product is stocked at only one shopify Location.

Problem:

The backend system runs on a scheduler and sometime it results oversell. [By the time it sets the correct qty, the store already have orders from the customer]

Solution:

If a product variant inventory quantity falls below 7 units, then update it to 0.
The figure “7“ can be fine tuned over the time.
Use Shopify Flow that triggers when the variant qty is updated and use Admin API action to set the qty of that variant to 0 if the remaining qty is less than 7.

Implementation:

  1. Generate access token with inventory scope. Check this article to generate new access token.

  2. Install Shopify Flow app.

  3. Create New Flow in the app

  4. Click “Start a trigger”

  5. Search for “Product Variant Inventory Quantity Changed“. This trigger will get triggered everytime when the variant quantity is changed due to any reason, eg. order created, manually updated, qty updated by some API etc

  6. Click on the “+“ button and then click on “condition”. We want to run this flow only for certain variants. So here we will add condition to check if it is one of the specific variant. This is quick but involves a lot of steps. I will add screenshots to follow along.

    Open new browser tab to follow next step, and once you have variant id, continue in the Flow app

    For the next step you will need an id of a location where this variant is stocked. Use another browser tab to find the location id so that we can easily continue from the current step in creating Flow.

    Then go to Settings>Locations>My Custom Location

    Now again go back to flow and use the location id in the Body.

  7. And we are done.
    At this moment the Flow is active and if all the conditions match, it will update the qty of that variant to 0

There are endless use cases of using Flow, and it is really a powerful no code solution