Re: Shopify Flow to track missed pick-up orders

Shopify Flow to track missed pick-up orders

AquaSprouts_Aqu
Shopify Partner
8 0 0

Hi everyone,

 

We're seeking assistance with a custom Shopify Flow workflow designed to identify and notify us about potentially missed pickups or stuck orders.

 

Desired Functionality:

  • Trigger: Flow should run automatically for orders meeting the following criteria:
    • Created within the last 2 days
    • Fulfilled status
    • Not cancelled
    • Shipping/transit status indicating the order is NOT in transit
  • Action: Send an email notification to a designated recipient(s) containing relevant order information.

Unfortunately, we haven't been able to achieve the desired functionality with our current Flow setup. We'd appreciate any insights, suggestions, or existing solutions that could help us track and address these potentially missed pick-ups. Please see screenshots and query below: 

 

created_at:<='{{ scheduledAt | date_minus: "2 days" }}' AND fulfillment_status:fulfilled AND NOT status:cancelled AND fulfillments_item.inTransitAt is not NONE

 

AquaSprouts-·-Flow-·-Shopify.png

AquaSprouts-·-Flow-·-Shopify (1).png

AquaSprouts-·-Flow-·-Shopify (2).png

AquaSprouts-·-Flow-·-Shopify (3).png

AquaSprouts_Aqu_0-1702407276330.png

 

Replies 7 (7)

ryan_i
Shopify Staff
25 6 9

Hi There, unfortunately the "inTransitAt" property of a fulfillment is not part of the orders query in the Admin GraphQL API (this is what backs the "Get Order Data" task). However, a condition could be used to ensure that at least one of the orders has a fulfillment that has no value for "inTransitAt" (see screenshot). This condition would replace the existing condition and count steps.

ryan_i_0-1702420289685.png

The send email action could be changed to highlight only the orders with these fulfillments (likely want to change the subject line too):

The unfulfilled orders:
{% for getOrderData_item in getOrderData %}
  {% assign in_transit_count = getOrderData_item.fulfillments | where: "inTransitAt" | size %}
  {% assign fulfillments_count = getOrderData_item.fulfillments | size %}
  {% if in_transit_count != fulfillments_count %}
    - {{getOrderData_item.name}} - ${{getOrderData_item.currentTotalPriceSet.shopMoney.amount}}
  {% endif %}
{% endfor %}

I'm not 100% certain on the liquid but this should give you a good start.

 

Thanks for the question!

Ryan

- Finding Flow useful? Leave us a review.
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
AquaSprouts_Aqu
Shopify Partner
8 0 0

Hi Ryan,
Thank you for the help and feedback! I implemented your suggested changes and am also still working on the liquid for the email piece.

It does look like the 'check if' action is returning some orders from the query with an 'empty' inTransitAt date.

 

Capture.JPG


However the liquid is not filtering in any order numbers to return. I tried printing out both the count variables you created and and they are equivalent, so it is not registering these 'empty' inTransitAt fields... maybe it is always being evaluated as `True` even if it is empty? I haven't used liquid before so I am trying to find the appropriate condition to try and flag these orders. I tried `== empty`, `==blank`, and `==null`. 

I also tried printing out all of the inTransitAt records in the email, and see this error for some orders:
`{“inTransitAt”=>Maestro::Util::LiquidHelper::MissingVariableDrop}`

So `inTransitAt` appears to be missing which makes sense, but any idea how to check for this in the liquid so that these orders are flagged?

Also, is there any way to test the liquid more easily? It is a challenge to experiment with as we only get one flow run every email. Also if there's any other more detailed liquid documentation that would be helpful. Much appreciated! 

AquaSprouts_Aqu
Shopify Partner
8 0 0

AquaSprouts-·-Flow-·-Shopify (4).png

paul_n
Shopify Staff
1771 194 414

That "where" is effectively like a loop. I'm not sure that it properly respects "blank" or other special variables like "empty". I might try instead:

 

{% for getOrderData_item in getOrderData %}
{% assign in_transit_count = 0 %}
{% assign fulfillments_count = getOrderData_item.fulfillments | size %}
{% for f in getOrderData_item.fulfillments %}  
  {% if f.inTransitAt != blank %}
    {% assign in_transit_count = in_transit_count | plus: "1" %}
  {% endif %} 
{% endfor %}
  {% if in_transit_count != fulfillments_count %}
    - {{getOrderData_item.name}} 
    - ${{getOrderData_item.currentTotalPriceSet.shopMoney.amount}}
  {% endif %}
{% endfor %}

 

Paul_N | Flow Product 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.
AquaSprouts_Aqu
Shopify Partner
8 0 0

Thanks Paul for the assistance!

I tried your logic and I am no longer getting that "MissingVariableDrop" error, but these 'empty' inTransitAt dates are still not getting flagged. When I print out the field in quotes I get a blank/empty string (``). But it seems like these missing dates still !=blank so the counts are the same for every order.

I've tried a few combinations such as: f.inTransitAt != nil and f.inTransitAt != "" and f.inTransitAt !=blank and f.inTransitAt !=empty but the condition is still being met for these 'empty' orders. I also tried if f.inTransitAt and that is evaluated as True as well.

It seems like we are close and if we could just correctly identify these 'empty' dates Are there any other special values that could correspond to this field when it is "empty"?

Appreciate the help with this.

image.png

paul_n
Shopify Staff
1771 194 414

Hmmm I think that plus: "1" needs to be plus: 1...it's probably just silently skipping it 

 

 

Paul_N | Flow Product 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.

lovehuvet
Excursionist
15 0 8

Could you please share how you created the "get order data" entry? I would like to duplicate this flow but can't figure it out.