Magento – Pending Payment Order Lifetime doesn’t expire or cancel orders

cancel-ordersmagento-cronmagento2order-statusorders

Preconditions:

  • Magento Open Source version 2.2.8
  • PHP 7.1.29, MySQL 5.6, Apache 2.4.
  • Clean install. No extensions or themes installed.

Steps to reproduce

1) Go to Stores -> Configuration -> Sales -> Sales -> Orders Cron Settings -> Pending Payment Order Lifetime (minutes)

2) Set "Pending Payment Order Lifetime" to 1 minute.

3) Create a order using a offline payment method such as "Check / Money order"

Expected result

We expect the created order to be cancelled and re-stock items after 1 minute in pending status.

Even though in user guide doesn't explicit say that the order will be cancelled it do imply it: https://docs.magento.com/m2/ce/user_guide/sales/order-pending-payment-lifetime.html

Actual result

Order keeps in "pending" status forever unless it's cancelled by the admin.

Best Answer

The "Pending Payment Order Lifetime" is only related to orders which are in the state "Pending Payment", e.g. if the customer has entered the online transaction payment process and cancels or quits the payment process. Then the order in Magento 2 will stay in the state "Pending Payment". After the timeout of "Pending Payment Order Lifetime" is reached, these orders will be automatically canceled by the Magento cronjob.

In your case you created an order with an offline payment method and the order will stay at the state "pending", because the payment transaction was not online. Instead you used an offline payment method (Check/Money order).

Related Topic