Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How can I accurately retrieve a customer's most recent order in Shopify Flow?

How can I accurately retrieve a customer's most recent order in Shopify Flow?

hostilearth
Shopify Partner
39 0 6
  • order.customer.lastOrder.shippingAddress.address1 is not returning the last order but rather the customer's first order
  • Get order data (customer_id:{{order.customer.legacyResourceId}} AND created_at:>='{{ "now" | date_minus:"1 day" }}') returns the last X orders, but it includes the order that triggered the flow. This means if 1 order is returned it will be the order that triggered the flow and not the previous order.

If customer.lastOrder doesn't return the last order, and a get order data query includes the order that triggered the flow, how do I get the customer's previous order?

 

I have tried getting the last 2 orders from a get order data query, but I don't know how to skip the first entry, and I have tried editing the query to change "now" to something like "1 hour" but it doesn't work. Here is the query:

 

customer_id:{{order.customer.legacyResourceId}} AND created_at:>='{{ "now" | date_minus:"1 day" }}'

 

If I can get the query to return results that skip the last few minutes up to X days, it should work.

Replies 0 (0)