Shopify Flow: avoid race condition with external API

Shopify Flow: avoid race condition with external API

Tim_Richardson
Shopify Partner
15 1 2

Shopify Flow can modify an order, example add a promotional product.

If Shopify is integrated with a third party app, how can we give the flow a chance to modify the order before the API picks up the new order? This is a typical B2C config, pay on checkout.  Is there an opportunity to put a paid order on hold until Flow finishes changing the order?

Replies 2 (2)

Jason
Shopify Partner
11207 226 2319

What's the logic to determine an order being complete? That's what is going to help the middleware know whether to take action or not. One path to consider would be to tag the order so the external system can choose to ignore orders without that tag.

When an order is created/paid you can expect that a webhook or automated job is going to pick up that order so there's not an hold stage you can inject before that point. So adding properties to the order can help identify a custom stage.

If the external app isn't something you have control over you might find there's not a solve. It really depends on how that works to pull in data.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★

DaveMcV
Shopify Staff
104 31 31

Hi Tim_Richardson,

 

As Jason mentioned, this is because Flow and the third party app are listening to the same webhook and a race condition is created.

 

If you need Flow to act first before the third party app, you could investigate using Flow's `Send HTTP Request` action to interact with the app's API instead of relying on the Webhook, but this may not be possible. Depending on the third party app, it may have a Flow Connector, so look for that in your editor too.

DaveMcV | Flow Development Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.