Description
Preconditions and environment
- Reproducible and tested on 2.4.6-p1 and 2.4.6-p2.
The sales_clean_orders cronjob is run every hour, on the hour. This is set it in the crobtab.xml at vendor/magento/module-sales/etc
<job name="sales_clean_orders" instance="Magento\Sales\Model\CronJob\CleanExpiredOrders" method="execute"> <schedule>0 * * * *</schedule> </job>
This cancels orders with "Pending Payment" status correctly. However, it does this once per hour, as set by the cron.
There is a setting to reduce order pending lifetime in Stores > Configuration >Sales > Sales > Orders Cron Settings >Pending Payment Order Lifetime (minutes)
If you set this to anything less than an hour, the order stays in Pending Payment status until the sales_clean_orders cron is run (once an hour), it doesn't trigger the cron any earlier. If the time is set to more than an hour then this setting works as expected. The default setting of 8 hours works as expected.
Steps to reproduce
Navigate to setting:
Stores > Configuration >Sales > Sales > Orders Cron Settings >Pending Payment Order Lifetime (minutes).
Change to a value less than 60 minutes. E.g 10 minutes.
Expected result
Pending Payment orders are Closed when time value set is reached.
Actual result
Payment Pending orders are not Closed until the sales_clean_orders cron is run every hour.
Additional information
I can tell that the time in the Pending Payment Order Lifetime (minutes) is honoured in some way, for example:
If I set the value to 15 minutes and I place an order at 13:50, when the cron sales_clean_orders is ran at 14:00, the order remains pending (as 15 minutes had not passed - 5 minutes remain). This should, in theory, change to Cancelled status at 14:05. In reality it will not be changed to Cancelled until 15:00 when the next sales_clean_order cron is ran.
If the cronjob time for sales_clean_orders is edited down to run more frequently, for example, every five minutes <schedule>*/5 * * * *</schedule>
then this runs a bit more accurately as the cron checks for orders to cancel more frequently.
In reality, should the minutes set in "Pending Payment Order Lifetime (minutes)." not dictate how often the sales_clean_orders cron is run?
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.