Clear the stale order backlog

WooCommerceIntermediate~15 min

Before you start

WooCommerce enabled, with the order list, status, and note abilities turned on. The status write ability stays off until you switch it on.

Most stores collect a tail of orders that never went anywhere: card failures, checkouts a customer abandoned at the payment step, pending orders from a gateway that never called back. They sit in failed or pending forever and clutter every count and report. This finds them and clears them, but only ever changes their status. It does not delete orders, so the record stays intact.

The prompt
I want to clear out stale orders. First, change nothing: list every order
still in [failed] or [pending] that is older than [60 days], with its number,
date, age, and total, so I can see the backlog.
Show me that candidate list and stop. Do not change anything yet.
Once I approve the list, set the ones I confirm to [cancelled] in small
batches, show me each batch as it goes, and add a note to each order saying
it was cancelled as an abandoned checkout during backlog cleanup. Do not
delete anything. At the end, give me the list of orders you changed and their
new status.

Why this is safe to run

This is a partial-automation recipe, and here is the honest line on scope: it changes order status and adds notes, and that is all it can do. It cannot delete an order, empty the trash, or touch payment data, so the worst case is an order set to cancelled that you set back afterward. A status change is reversible; a delete would not be, and this recipe has no delete in it.

The read comes first. Listing the backlog writes nothing, so you approve the exact orders before a single status flips. From there the change runs in batches you watch, only on the orders you confirmed, with a note left on each explaining why. Every write is checked against the capability of the user you bound the agent to and lands in the Activity Log with the order it touched.

Already connected? You do not have to paste this. Ask your agent for the “clear the stale order backlog” recipe, or just tell it which statuses and how old, and it runs the same reads-first flow on your own store.

How it works

  1. List orders stuck in failed or pending, older than the cutoff date you set.
  2. Show the candidate list with age, total, and status, and wait for your approval.
  3. Change the approved orders to cancelled in small batches, pausing to show each batch.
  4. Leave a note on each one recording why it was cancelled.
  5. Return the list of orders it changed and their new status.

Questions

Does this delete the old orders?
No. It only changes their status, usually to cancelled. The orders stay in your store with their full history, so nothing is removed and you can set a status back if you cancelled one too early.
Could it cancel an order a customer might still pay?
Only if you approve it. That is what the cutoff date and the candidate list are for: you decide how old a failed or pending order must be before it counts as abandoned, and you see every order before anything changes.