AI Reports

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

  1. Go to Sales › Orders › Filters.
  2. 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

Related

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn