Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Admin settings for the module are placed in Stores -> Configuration -> MageSuite -> Auto order cancel

...

Settings:

Setting nameField

ValueOptions

Comment

Enable cancellation of unpaid orders

 Yes/No 

Disabled by default

Payment Methods

List of payment methods available in the shop

Please select the bank transfer methods to auto cancel.

Time to cancel orders (days)

number

Number of days after which an unpaid order will be canceled, default: 7

Cancel orders cron schedule

crone schedule

Enter crone schedule, default: 30 3 * * *

...

Note

Add documentation for BE code

Cron runs execute method in file vendor/creativestyle/magesuite-auto-order-cancel/Cron/CancelOrders.php

Code Block
class CancelOrders
{
    public function execute()
    {
        .....
        $orderCanceller->execute();
    }
}

It runs also execute method in service vendor/creativestyle/magesuite-auto-order-cancel/Service/OrderCanceller.php

It calls method cancelUnpaidOrders where:

  • we get collection with orders which need to be canceled

  • than for each order all invoices are canceled and than given order is canceled

Code Block
class OrderCanceller
{
    public function execute():void
    {
        foreach ($this->storeManager->getStores() as $store) {
            .....
            $this->cancelUnpaidOrders($storeId);
        }
    }
    
    public function cancelUnpaidOrders(?int $storeId = null):void
    {
        $orders = $this->ordersToCancelCollection->getOrders($storeId);

        foreach ($orders as $order) {
            .....
                $this->cancelInvoices($order);
                $this->orderManagement->cancel($order->getEntityId());
            .....
        }
    }
    
    protected function cancelInvoices(\Magento\Sales\Model\Order $order):void
    {
        foreach ($order->getInvoiceCollection() as $invoice) {
            $invoice->cancel();
            .....
        }
    }
}

Frontend

The module does not provide any functionality for the storefront.