Magento 2 auto cancel order runs on one setting and one cron job. Pending Payment Order Lifetime, which defaults to 480 minutes, says how long an unpaid order may wait, and an hourly job cancels expired orders. It only touches orders in the Pending Payment status, so other statuses, such as Pending, aren’t covered natively.
Key takeaways
- Adobe’s documentation says the lifetime of orders with pending payments comes from the Orders Cron Settings. The default is 480 minutes, which is eight hours. The config path is sales/orders/delete_pending_after.
- In Magento’s own source code on GitHub, the cleanup job is named sales_clean_orders, and its schedule is the top of every hour.
- The job’s code reads the lifetime for each store, picks orders whose status is Pending Payment and whose last update is older than the lifetime, and cancels each one through the order management service.
- Orders in other statuses aren’t selected by that code, so an unpaid order sitting in Pending isn’t cancelled by this mechanism.
- If auto-cancel seems to do nothing, check cron first. Adobe says several Commerce features depend on cron, and that you must run cron twice for a task to be discovered and then run.
- We haven’t tested this on a live store, and we couldn’t verify how cancellation affects stock, so we say so wherever it matters.
Unpaid orders are a quiet source of mess. A customer starts a payment, closes the tab, and the order sits in your grid. Your team sees it, wonders whether it’s real, and either chases it or ignores it. Multiply that by a few hundred a month and you have a clutter problem, a reporting problem and, depending on how you handle stock, possibly an availability problem.
Magento has a built-in answer for part of this, and Magento 2 auto cancel order is the name most people search for. This guide explains exactly what that answer does, what it doesn’t, and how to fill the gaps. We’ve kept it specific on purpose, because the common advice online tends to skip the part that matters: which orders the native job picks up.
Here’s how we researched it. On 1 December 2026 we read Adobe’s documentation on scheduled order operations, order statuses, the Sales configuration path reference and cron configuration. We also read two files in Magento’s public repository on GitHub, in the 2.4-develop branch: the Sales module’s cron schedule file and the class that performs the cleanup. Where we describe what the code does, that’s our reading of those two files on that day, and code can differ in the version you run.
The limits: we haven’t run this on a live store for this guide, and we haven’t tested payment gateways. We also couldn’t verify what happens to stock when an order is cancelled, so we don’t make a claim about it. If you want a ready-made module instead of the native route, we’ve covered one in our guide to the auto cancel order module for Magento 2, and this article is about the platform’s own behaviour.
What is auto cancel order in Magento 2?
Magento 2 auto cancel order is a built-in cleanup that cancels orders left unpaid for too long. The mechanism is narrow on purpose: it applies to orders with pending payments, and it’s controlled by a single time setting.
Adobe’s page on scheduled order operations puts it this way. The lifetime of orders with pending payments is determined by the Orders Cron Settings configuration, and the default is 480 minutes, or eight hours. Cron does the work.
It helps to remember what “pending payment” means. Adobe’s order status page describes the Pending Payment status (code pending_payment) as the status used if the order is created and PayPal or a similar payment method is used, where the customer was directed to the payment gateway’s website but no return information has been received yet. The status changes when the customer pays.
The same page lists the Canceled status and explains it: it’s assigned manually in the Admin or, for some payment gateways, when the customer doesn’t pay within the specified time. That last clause is the one that matters here. The native cleanup is the “specified time” for Pending Payment orders.
So, in short:
| Part | What it is |
|---|---|
| Setting | Pending Payment Order Lifetime (minutes) |
| Default | 480 minutes (eight hours), per Adobe |
| Config path | sales/orders/delete_pending_after |
| Worker | Cron job sales_clean_orders |
| Target | Orders whose status is Pending Payment |
| Action | Cancel the order |
If you want the wider view of how order states and statuses relate, our guide on order status management in Magento 2 goes through them.
How do you set the Pending Payment Order Lifetime?
You set it in the Admin. Adobe’s steps are short, and we’ve repeated them here as the page gives them.
- On the Admin sidebar, go to Stores, then Configuration.
- In the left panel, expand Sales and choose Sales underneath.
- Expand the Orders Cron Settings section.
- For Pending Payment Order Lifetime (minutes), enter the number of minutes before a pending payment expires.
- Click Save Config.
The value is in minutes, so eight hours is 480 and 24 hours is 1440. Adobe’s config path reference confirms the setting’s path as sales/orders/delete_pending_after. If you manage configuration through files or the command line, that’s the path to use.
One detail from the code: the cleanup reads the lifetime for each store separately. In the file we read, the class asks the stores configuration for the value at that path and loops over the results by store. That suggests you can set different lifetimes in different scopes, though we haven’t tested it, and you should check the scope options in your own Admin.
What number should you pick for Magento 2 auto cancel order? Don’t copy ours, because there isn’t one. The right value depends on how long your payment methods take to confirm. If a gateway can take a long time to send its confirmation, a short lifetime could cancel an order a customer then pays for. We’ll come back to this in a later section, because it’s the main risk.
How does the sales_clean_orders cron job work?
It’s a small job with a clear rule. Here’s what we found in Magento’s repository on 1 December 2026.
The Sales module’s cron schedule file defines a job named sales_clean_orders, in the default cron group. It runs the class Magento\Sales\Model\CronJob\CleanExpiredOrders, and its schedule is “0 * * * *”, which means the start of every hour.
The class does the following, in our reading of the code:
- It asks the stores configuration for the value at sales/orders/delete_pending_after, which gives a lifetime for each store.
- For each store, it builds a list of orders for that store whose status is Pending Payment.
- It narrows the list to orders where the number of seconds since the order’s last update is greater than the lifetime multiplied by 60.
- For each order that matches, it calls the order management service to cancel the order.
Three consequences follow.
The clock starts at the last update, not the creation time. The query compares against the updated_at value. If something updates the order record after it’s created, the clock restarts from that update. We haven’t tested what updates count, so treat this as an effect to watch for, not a rule.
The job is hourly, so cancellation is never exact. An order that expires at 10:05 isn’t cancelled until the job’s next run, at 11:00 or later. If you set the lifetime to 60 minutes, expect orders to wait between 60 and 120 minutes. This follows from the schedule in the file.
It cancels through the order management service. The job doesn’t change a status field directly. It calls the same kind of cancel operation the rest of the system uses, so other parts of Magento that listen to cancellation events can react. We haven’t verified what those listeners do on your store.
One caution about reading code. We read the 2.4-develop branch, which may include changes that aren’t in your release. Before you rely on any detail here, ask your developer to check the file in your own version, which is a few minutes’ work.
Which orders does Magento 2 auto cancel order not cancel?
Anything that isn’t in the Pending Payment status. This is the gap that catches most stores, so it’s worth being precise.
In the code we read, the list of candidate orders is filtered by status, and the value used is the Pending Payment state. So an order that sits in another status, however old, isn’t picked up by this job.
Here’s how Adobe’s order status page describes the statuses that matter for unpaid orders.
| Status | Adobe’s description | Picked up by the native job? |
|---|---|---|
| Pending Payment | Used if the order is created and PayPal or a similar payment method is used; the customer was sent to the gateway but no return information has been received | Yes, by the code we read |
| Pending | No invoice and shipments have been submitted | No |
| Payment Review | Appears when PayPal payment review is turned on | No |
| On Hold | Can only be assigned manually | No |
| Canceled | Assigned manually in the Admin or, for some gateways, when the customer doesn’t pay in time | Already cancelled |
The “picked up” column is our reading of the code, not a statement from Adobe.
What does this mean for your store? It depends on which status your payment methods give a new order. Adobe’s page describes Pending Payment as the status for PayPal-style flows where the customer leaves for a gateway. Other methods may create orders in other statuses. We didn’t test your payment methods, so we can’t tell you which ones land where.
The way to find out is simple. Look at your Orders grid, filter by status, and see where your old unpaid orders sit. If they’re in Pending Payment, the native job should handle them once cron runs. If they’re in Pending, it won’t, and you’ll need one of the options in the section below.
This is also where the question of method matters. A customer who chose a method that doesn’t redirect to a gateway may have a perfectly valid order that simply hasn’t been paid yet, such as a payment you expect to arrive later. Cancelling those automatically could be wrong for your business, which is one reason Magento’s native job doesn’t do it. That’s our reasoning, not a statement from Adobe.
Why is Magento 2 auto cancel order not working?
Check these in order when Magento 2 auto cancel order seems to do nothing. Most problems come from cron, and the rest come from status or scope.
1. Is cron running? Adobe says several Commerce features require at least one cron job, and that Commerce depends on proper cron configuration for many important system functions. Check it with the crontab. Adobe’s documentation says that since version 2.2, Commerce creates a crontab for you, and you can install it with bin/magento cron:install. A sample entry runs cron:run every minute under the file system owner.
2. Has cron run twice? Adobe’s cron page says you must run cron twice: the first time to discover tasks to run, and the second time to run them. The second run must occur on or after the scheduled time for every task. On a fresh install, a single run won’t do it.
3. Is the job scheduled and finishing? Adobe’s page says all cron data is written to the cron_schedule table, which includes the job code, status, and created, scheduled, executed and finished dates. You can see records with SELECT * from cron_schedule; in the database. Look for the job code sales_clean_orders and check whether its status is success, missed or error.
4. What do the logs say? Adobe says cron information is logged in var/log/cron.log by default, and that failed jobs with ERROR and MISSED statuses are also logged to support_report.log. Jobs with an ERROR status are logged as critical in exception.log.
5. Is the order really in Pending Payment? If it’s in another status, the job doesn’t select it.
6. Is the lifetime set at the right scope? The code reads the value for each store. A lifetime saved at one scope may not apply to another store view.
7. Has the order been updated recently? Because the code compares against the last update, a recent change to the order restarts the timer.
8. Has enough time passed? With an hourly schedule and a lifetime in minutes, an order can wait longer than you expect. If you set 480 minutes, expect cancellation sometime after eight hours and before nine.
9. Is a payment extension doing its own thing? Adobe’s status page says Canceled is assigned for some payment gateways when the customer doesn’t pay within the specified time. A gateway module may have its own rule alongside Magento’s.
If none of these explains it, ask your developer to run the job’s class manually in a development environment and watch what it selects. And if cron health is a recurring issue, our guides on Magento DevOps and Magento maintenance cover keeping it healthy.
How do you check what the job did?
To audit Magento 2 auto cancel order, use three sources: the cron table, the Orders grid and each order’s history.
The cron table. Adobe documents the cron_schedule table as a history of cron jobs, with the job code, status and several dates. Look for rows with the code sales_clean_orders and compare their scheduled and finished times with the hours you expect.
The Orders grid. Filter by status. If the job is doing its work, you’ll see cancelled orders appear and old Pending Payment orders disappear. Check a few examples to confirm the dates.
The order itself. Open a cancelled order and look at its comments and history. We haven’t checked what text Magento records for a cron cancellation, so don’t rely on a specific message. Check what yours shows.
One more tip: Adobe’s scheduled order operations page also describes asynchronous grid indexing, which updates the orders, invoices, shipments and credit memos grids on cron. Adobe says it can avoid locks that occur when data is saved. If you enable it, your grids update on a schedule too, and Adobe says that for best results cron should run once every minute. So a cancelled order may take a moment to show its new status in the grid. We haven’t tested the delay.
How do you cancel other unpaid orders automatically?
For Magento 2 auto cancel order beyond Pending Payment, you have four options, and the right one depends on your payment flow and your tolerance for risk. Here they are, with the trade-offs we’d weigh.
| Option | What it is | Trade-off |
|---|---|---|
| Use the native setting only | Rely on Pending Payment Order Lifetime | Simple and supported, but limited to the Pending Payment status |
| Install an extension | A module that adds rules for other statuses or payment methods | Faster, but check maintenance, upgrade support and what it cancels |
| Build a custom cron job | Your own scheduled job with your own filter | Full control, but you own the code and the testing |
| Cancel by hand | An admin cancels orders from the grid | No risk of wrong cancellations, but it doesn’t scale |
For the extension route, our auto cancel order module guide describes one, and our article on how to cancel an order in Magento 2 covers the manual route.
If you go the custom route, the native job gives you a template. It reads a configuration value, selects orders with a filter, and calls the order management service to cancel each one. Your version would change the filter and the rule. Here are the design questions we’d settle before writing any code:
- Which statuses and payment methods are in scope? Be explicit. List them.
- How old must an order be? Pick a rule and make it configurable, like the native setting.
- What must be true before cancelling? For example, no invoice, no payment captured, no shipment. Adobe’s status page describes Pending as “no invoice and shipments have been submitted,” which is a useful starting point, but check your own flows.
- Which scope applies? Decide whether the rule is per store, like the native job, or global.
- How will you log it? Record which orders were cancelled and why, so support can answer a customer’s question.
- What happens on failure? One order that can’t be cancelled shouldn’t stop the others.
- How will you test it? On a staging copy, with a mix of order types, before it touches production.
We haven’t written or tested a custom job for this guide, and we won’t give code we haven’t run. If you’d like one built and tested properly, our Magento development services team can scope it, and you can get in touch to start.
Should you shorten the 480-minute default?
Maybe, but only after you’ve checked how your payment methods behave. The default is Adobe’s, and the right number depends on how long a customer can take to pay and how long a gateway can take to confirm.
Think of the lifetime as a bet on one question: after how many minutes is an unpaid order almost certainly abandoned? Set it too long, and your grid fills with dead orders for hours. Set it too short, and you risk cancelling an order that a customer completes a little later, or one whose payment confirmation is delayed.
Here’s how we’d approach the decision.
- Ask your gateway. How long can a customer take on the payment page, and how long can the confirmation take to reach your store? Your gateway’s documentation is the source, not ours. We didn’t test any gateway for this guide.
- Look at your own data. In the Orders grid, check how long successful Pending Payment orders typically took to change status. If the slowest legitimate orders took, say, an hour, a lifetime shorter than that would be risky. That example is hypothetical, so use your real numbers.
- Add a safety margin. Because the job is hourly, orders wait a bit past the lifetime anyway, but don’t count on the delay as protection.
- Change it on staging first. Watch what happens for a few days.
- Change it in small steps. Moving from 480 to 240 is easier to reason about than jumping to 30.
- Keep a note of what you changed and when. If a customer later says their paid order was cancelled, you’ll want a record.
What about the opposite problem, a store that sells limited stock? If unpaid orders hold stock while they wait, a shorter lifetime may help. But we couldn’t verify how stock is handled on cancellation in your setup, so we won’t make that claim. Check it on staging: place a test order, leave it unpaid, let the job cancel it, and see what happens to the salable quantity.
Does auto-cancelling affect emails, reports and integrations?
It can. We haven’t traced every side effect, and the effects depend on your extensions, so here is a checklist of things to check rather than a list of facts.
- Customer emails. Does your store send a cancellation email? Decide whether you want customers to receive one for abandoned payments. We didn’t verify what Magento sends in this case.
- Reports. Cancelled orders may appear differently in your sales reports. Adobe’s scheduled operations page mentions aggregated reporting jobs on a schedule, so figures may not update instantly.
- Integrations. If you send orders to an ERP, warehouse or CRM, check what each system does when an order changes to Canceled. Our guide on Magento ERP integration covers the wider integration picture.
- Analytics. If your analytics tool counts orders at placement, cancelled orders may skew conversion numbers.
- Customer service. Tell your support team what the rule is, so they can answer a customer who calls about a cancelled order.
The simplest way to find out is to place a test order, leave it unpaid, wait for the job, and watch every system downstream. It takes a morning and avoids an unpleasant surprise.
What couldn’t we verify?
Here’s what we left out because we couldn’t confirm it from the sources we read.
| Question | What we found |
|---|---|
| Does cancellation release stock? | Not verified. Test on staging |
| Which updates restart the timer? | Not tested. The code compares against the last update time |
| Which statuses do your payment methods use? | Depends on the method. Check your Orders grid |
| What message does Magento record on cancellation? | Not checked |
| Does the scope setting work per store view in your version? | Not tested. The code reads the value per store |
| Is the code in your release the same as 2.4-develop? | Not checked. Ask your developer to compare |
| What does a payment gateway module do on its own? | Not covered. Check its documentation |
| Is there a way to cancel orders in other statuses natively? | Not found in the pages we read |
If any of these affects a decision, test it. Don’t assume.
Frequently asked questions
How do I enable auto cancel for orders in Magento 2?
Magento 2 auto cancel order is controlled by one setting. Go to Stores, then Configuration, then Sales, then Sales, and expand Orders Cron Settings. Set Pending Payment Order Lifetime (minutes) and save. Adobe says the default is 480 minutes. Cron must be running for the cleanup to work.
What is the default pending payment order lifetime?
Adobe’s documentation says the default is 480 minutes, which is eight hours. The setting’s config path is sales/orders/delete_pending_after.
Why isn’t my pending payment order being cancelled?
Check that cron is running and has run twice, that the sales_clean_orders job appears in the cron_schedule table without errors, that the order is really in the Pending Payment status, and that enough time has passed. The job runs hourly, so cancellation can lag the lifetime by up to an hour.
Does Magento cancel orders in the Pending status automatically?
Not through the native cleanup. In the code we read, the job selects orders whose status is Pending Payment. Orders in Pending or other statuses need an extension, a custom job or manual cancellation.
How often does the cancel job run?
In Magento’s repository, the sales_clean_orders job has the schedule “0 * * * *”, which means once every hour at the start of the hour. Check the file in your own version.
Can I set different lifetimes for different stores?
The code reads the lifetime for each store, so scope-level values look possible. We haven’t tested it, so check the scope options on the setting in your Admin and test on staging.
Can I cancel orders manually instead?
Yes. Adobe’s order status page says Canceled is assigned manually in the Admin or, for some gateways, when the customer doesn’t pay in time. Our guide on cancelling an order in Magento 2 covers the manual route.
The bottom line
The Magento 2 auto cancel order feature is small and specific. One setting, Pending Payment Order Lifetime, defaulting to 480 minutes, and one hourly cron job that cancels expired orders in the Pending Payment status. Beyond that status, you’ll need an extension, a custom job or a manual process.
Before you change anything in Magento 2 auto cancel order, look at where your old unpaid orders actually sit. If they’re in Pending Payment, check that cron is healthy and the lifetime suits your gateways. If they sit elsewhere, decide on a rule before you automate anything, and test it on staging.
If you want help checking your cron setup or building a safe cancellation rule, our Magento development services team can take it on, or you can contact us to talk it through.

