Magento 2 SQL queries › Orders and sales
Which orders are still pending after 3 days?
Short answer: Filter the order grid by status Pending and an old purchase date. The query below also catches pending payment orders, which the grid shows under a different status.
In the Magento admin
- Go to Sales › Orders › Filters.
- Set Status to Pending and Purchase Date to before 3 days ago. Repeat for Pending Payment.
With one query
These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.
Works on Magento Open Source and Adobe Commerce:
SELECT o.increment_id, o.created_at, o.state, o.status,
o.customer_email, o.base_grand_total
FROM sales_order o
WHERE o.state IN ('new', 'pending_payment')
AND o.created_at < NOW() - INTERVAL 3 DAY
ORDER BY o.created_at;
Good to know
- Magento cancels unpaid pending payment orders by itself after the Pending Payment Order Lifetime (Stores › Configuration › Sales › Sales › Orders Cron Settings, 480 minutes by default), but only if cron is running. Old ones here are a sign it isn't.
- Orders in new state with a successful payment usually mean the payment callback failed; check the payment record before canceling.