Getting order details from the order before last order

Topic summary

Goal: Automate a Shopify Flow that detects customers placing two or more orders within 3 hours and sends a notification listing the two specific order numbers (e.g., “Your last two orders are #1001 and #1002.”).

Issue: The last order is the trigger, but the Flow variable (getOrderData) returns both orders together. A simple loop prints the names concatenated (“#1001#1002”) rather than formatted separately.

Proposed approach: Use a Liquid loop with a conditional to insert a separator between the two orders:

  • Loop over getOrderData and print each order’s name.
  • Use forloop.first to add “ and ” after the first item so the output becomes “#1001 and #1002”.

Key snippet (concept):

  • For each getOrderData_item in getOrderData, output getOrderData_item.name, and if forloop.first, append “ and ”.

Status: A formatting solution was suggested; no confirmation yet from the original poster. Discussion remains open.

Summarized with AI on January 7. AI used: gpt-5.

Hello, I am trying to create an automation where customers who placed two or more orders in the past 3 hours would receive a notification. I would like to also let the customer know which are those two specific orders, say #1002 and #1001. My issue is that the last order will always be the triggering order. Thus:

{%- for getOrderData_item in getOrderData -%}
{{- getOrderData_item.name -}}
{%- endfor -%}

won’t work, as it would return #1002 (from our example). Any ideas how I can reference the order from before last order?

1 Like

I don’t think this is an issue. The get order data will return both orders

1 Like

That’s true. However, it will always return both orders. What I was trying to achieve is to use them separately as values. For example, the desired result should be:

“Your last two orders are #1001 and #1002.”

Currently it’s returning: “#1001#1002”

Maybe this?

{%- for getOrderData_item in getOrderData -%}
{{- getOrderData_item.name }}{% if forloop.first %} and {% endif -%}
{%- endfor -%}