Compare order value vs that customer's previous order

Topic summary

A merchant wants to create a Shopify Flow workflow that triggers when a customer places their 2nd or 3rd order, comparing the order value against their previous order. The goal is to identify when a second order falls below a threshold (e.g., $728) after a first order exceeded it, enabling targeted follow-up promotions.

Key Challenge:
The user struggled with using the “Get order data” action to retrieve and compare the last two orders’ subtotals.

Solution Provided:

  • Sort orders by “Created at” in descending order to get the most recent orders first
  • Use query filter “Placed by same customer in last day” (removing the date constraint)
  • Since Flow conditions cannot directly compare two list items, use the “Run code” action
  • The code checks if customer has 2+ orders, parses subtotals of current and previous orders, then returns a boolean “followUp” value
  • A subsequent condition step checks if followUp is true to trigger actions

Important Note:
The Customer.numberOfOrders property has a 1-2 hour delay in updating, so that check was removed from the workflow.

Outcome:
Complete working code examples were provided for both scenarios: any order after the first, and specifically for 2nd/3rd orders only.

Summarized with AI on November 7. AI used: claude-sonnet-4-5-20250929.

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” }}’"