I want to trigger a workflow when a customer makes an order and it’s their 2nd (or 3rd) order.
Specifically I am trying to figure out if the first order is above $X amount and the second order is below $X amount so that I can then respond to that customer to try and increase their next sale / offer a promo, etc.
Shopify help suggested using the following:
Use the Order fulfilled trigger to start your workflow when an order is fulfilled.
Add a condition to check if the customer has made at least two orders.
Retrieve the details of the last two orders using the Get order data action.
Compare the subtotal of the second order (the one being fulfilled) with your specified amount (below $X) and the subtotal of the first order (above $X).
Where I am stuck is in using the “get order data” action. No idea how to make this comparison. Any help is appreciated. When I asked Shopify help to throw that example in my workflow or show me, they took 20 minutes to then tell me to use a template instead (which doesn’t do what I’m requesting).
To get the last two orders, you should use Sort data by “Created at” in Descending order. Sorting in descending order ensures that the most recent orders are at the top of the list. Once sorted, you can then retrieve the first two orders from this sorted list.
One more thing, for “Select a query to filter data” choose “Placed by same customer in last day” and then remove " AND created_at:>=‘{{ “now” | date_minus:“1 day” }}’"
I guess my next question is how to I then do the comparison from order 1 to order 2 after completing the query?
What I’ve tried here is adding the condition that one of the orders from the list that is generated is >$728 (my threshold number). I think… Is this accurate or is there a more elegant / foolproof way to get to this answer? THANKS!
You cannot compare 2 separate list items in a condition step. You can use the “Run code” action, either by doing the comparison there, or by splitting the 2 orders and returning the data you need for a subsequent condition.
Thanks Paul.
Any resources on what that code might look like? I run a store for a living, not code. I have no idea how to code a comparison or split the orders and return the data I need for a subsequent condition.
It was always showing 0 even though I had at least 4 orders. Apparently it takes 1-2hr for Custom.numberOfOrders to update when orders are created: https://community.shopify.com/post/2217109
Notice: I removed the step “Check if… Customer number of orders is equal to 2”
In Run Code:
We check if the customers orders are less than 2 here and only proceed with the comparison if the customer has 2 or more orders (for exactly the 2nd and 3rd order see reply)