Tag orders that are 30 days overdue with Flow

Topic summary

Goal: Automatically tag orders that are 30 days past their payment terms due date so A/R can filter them in Shopify admin.

Data points: paymentTerms includes overdue (boolean), dueInDays, and paymentSchedules.nodes.dueAt (due date). Days past due must be calculated; filter by payment status PENDING is also needed.

Proposed approach (scheduled scan): Scheduled trigger → get orders (older than 30 days, status PENDING) → run code to compute date difference → for each order add tag. Blocked because Flow’s “Run code” cannot currently execute inside a For Each loop.

Alternative (forward-only): Trigger on order creation or “Payment Schedule is Due” → wait 30 days → run code/check status → add tag. Works only for new orders; the requester is fine manually tagging older ones.

Current blocker: Using the “Payment Schedule is Due” path, the Add tag action fails due to a Flow quirk where the order on payment terms can be nil, so actions requiring a non-nil order are disallowed. A fix is planned in the next few weeks.

Workarounds now: Use “Get order data” (limit 1) → For each → Add order tags, or send an HTTP request calling the tagsAdd mutation. Status: requester will wait for the fix; issue remains open pending rollout.

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

Hi there!

Can someone help me configure Flow to tag orders that are past due by 30 days?

Thanks!

1 Like

Can you show what you mean by past due? What feature are you using for that?

Hi Paul!

When we send an invoice with payment terms like Net 30 and the invoice still hasn’t paid even 30 days after the due date. I want to filter those orders by a tag on the orders page so our accounts receivable team can easily know which are 30 days past due their due date.

Thanks.

Did a bit of research. Here’s what the data looks like for an overdue order:

"paymentTerms": {
        "dueInDays": 30,
        "overdue": true,
        "paymentTermsType": "NET",
        "paymentSchedules": {
          "nodes": [
            {
              "amount": {
                "amount": "15.0"
              },
              "dueAt": "2024-01-05T16:21:46Z"
            }
          ]
        },
        "draftOrder": null
      },

You can get that it’s overdue, and the due date, but you would have to do math to calculate how many days it is past due.

I think you would need the workflow something like:

  • Scheduled time trigger
  • Get order data (order than 30 days and with a payment status of PENDING)
  • Run code (to calculate the date difference)
  • For each (order)
    • If overdue > 30
      • Add tag

The problem with this is that “Run code” cannot yet be placed inside of a For Each loop (the action was just released). So this doesn’t work

You could also do:

  • Order created
  • Wait 30 days
  • Run code to check dates
  • If still PENDING
    • add tag

The downside of this is that it only works going forward.

Hi Paul! Thanks for the information. I think the second option will actually work just fine and I can back track and manually tag the older ones. I was thinking of starting this way:

  • Payment Schedule is Due (this is in the template for sending payment reminders)

  • Wait 30 days (so 30 days past its due date)

  • Check if still pending

  • Add tag.

When I try this I get stuck at the tagging part…

The issue there is a quirk of Flow. Basically the order on payment terms can be “nil” so we don’t allow using it with an action that requires it to not be nil. As luck has it, we are planning to fix this in the next few weeks, assuming we don’t hit any unexpected issues.

You could wait. If it’s urgent, I think there are some ways around it:

Get order data to get same order (LIMIT results to 1) → For each loop → Add order tags

Send http request to call the tagsAdd mutation directly

That’s good to know! Thank you! I think I’ll wait till the fix comes through in that case. Thank you for your help :slightly_smiling_face: