How to automate order fulfillment using Flow?

no_robotocha
Shopify Partner
42 2 6

Hello, I'm trying to create a flow but keep getting stuck on the best way to do it. This is what I'm trying to do:

 

When ALL LINE ITEMS from an order, except [Line Item: Product ID], are set to FULFILLED

then

Set ALL LINE ITEMS to FULFILLED

 

Is this possible? I'm new to Flow and have only made a few simple automations. Happy to use the REST API if it's the best way.

 

Thanks, M

--
No, Robotocha!
Replies 4 (4)

TaskHusky
Shopify Expert
111 11 17

Try to set the Flow up this way:

  1. Trigger

    • Choose Order Updated.
  2. Conditions

    • Add condition: If All of the following conditions are true
      • Line item status > is > fulfilled.
      • Line item - Product ID > is not > [Line Item: Product ID].

    Note: You'll have to loop through all line items to check this condition. Shopify Flow supports "For each line item in order" to iterate over line items and run checks on each of them.

  3. Actions

    • Add action: Order > Update line items.
      • Set Line item status to fulfilled for all line items.
Zachary McClung, founder
Your Shopify Store Customized Your Way - 20,000 + Shopify Merchants Served
Clean Size Chart - Reduce Returns & Make More Money
no_robotocha
Shopify Partner
42 2 6

Hi Zachary,

 

Thanks for your suggestion. I'm not sure the correct way to loop through through to order contains [Line Item: Product ID] AND all other products in the order are fulfilled THEN set [Line Item: Product ID] to fulfilled.

 

Do you know how I would do this?

 

I have also found that it's not as simple as setting line item status to fulfilled as this is not yet an action, but I can cross that bridge with an HTTP request when I come to it.

--
No, Robotocha!

DaveMcV
Shopify Staff
78 25 24

Hi No_robotocha,

 

You'll want to look at using the Fulfillment Event Created trigger, then you an look at the order's fulfillments.

In the Condition, you can write the check for the Product ID using `order.fulfillments.fufillmentLineItems.lineItem.product.id`, then add a sub-condition on the loop that iterates through fulfillments to check status. You can adjust the All/Any/None logic and adjust the test to suit your exact use case:

  • All of Order / Fulfillments
    • All of Fulfillment line items
      • fulfillmentLineItems_item.lineItem.product.id = YOUR_PRODUCT_GID 
    • fulfillments_item.status = SUCCESS

DaveMcV_0-1695231654387.png

 

For the status update, Flow does not support that Action so you would need to use the Send HTTP Step (not available on Basic plan) to call the Admin API.

Hope that helps!

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.
no_robotocha
Shopify Partner
42 2 6

Hi Dave,

 

This is very helpful and seems close to solution. I've been trying to recreate and have a couple of follow-up questions:

  • In your image you have All of Order / Fulfillments box, then a All of Fulfillment line items box - how did you do this?
  • I still can't wrap my head around the logic i.e. if an order contains product x AND all other products in the order are fulfilled THEN set product x to fulfilled
  • We have Shopify Advanced plan, so I'm happy to use the Send HTTP action to solve this

Thanks, M

--
No, Robotocha!