https://github.com/magesuite/auto-order-completion
The module adds the possibility to enable auto invoicing and auto shipping for orders.
Installation
This module is optional.
composer require "creativestyle/magesuite-auto-order-completion" ^1.0.0
Admin settings
Admin settings for the module are placed in Stores -> Configuration -> Sales -> Auto order completion
Settings:
Field | Options | Comment |
---|---|---|
Enable auto invoicing | Yes/No | Default value: No |
Enable auto shipping | Yes/No | Default value: No |
Backend
Add documentation for BE code
Command for complete Orders
bin/magento order:complete
vendor/creativestyle/magesuite-auto-order-completion/Console/Command/CompleteOrders.php:27
class CompleteOrders extends \Symfony\Component\Console\Command\Command { protected function execute( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output ) { $this->orderProcessorFactory->create()->completeOrders(); } }
Cron for complete Orders
vendor/creativestyle/magesuite-auto-order-completion/Cron/CompletePendingOrders.php:20
class CompletePendingOrders { public function execute() { $this->orderProcessor->addGreaterThanDaysFilter(7)->completeOrders(); } }
Order processor
If auto invoicing enabled, than prepare Invoice
If auto shipping enabled, than create shipment
vendor/creativestyle/magesuite-auto-order-completion/Service/OrderProcessor.php:50
class OrderProcessor { public function completeOrders() { $collection = $this->getCollection(); ..... while ($page <= $lastPage) { $collection->setCurPage($page)->load(); foreach ($collection as $order) { try { $this->invoiceCreator->execute($order); $this->shipmentCreator->execute($order); } catch (\Exception $e) { $this->logger->error($e); } } ..... } return $this; } }
vendor/creativestyle/magesuite-auto-order-completion/Service/InvoiceCreator.php:37
class InvoiceCreator { public function execute(\Magento\Sales\Model\Order $order) { ..... $invoice = $this->invoiceManagement->prepareInvoice($order); $invoice->register(); ..... } }
vendor/magento/module-sales/Model/Service/InvoiceService.php:149
class InvoiceService implements InvoiceManagementInterface { /** * Creates an invoice based on the order and quantities provided. */ public function prepareInvoice( Order $order, array $orderItemsQtyToInvoice = [] ): InvoiceInterface { $invoice = $this->orderConverter->toInvoice($order); ..... $order->getInvoiceCollection()->addItem($invoice); return $invoice; } }
vendor/creativestyle/magesuite-auto-order-completion/Service/ShipmentCreator.php:25
class ShipmentCreator { public function execute(\Magento\Sales\Model\Order $order) { ..... $shipment = $this->shipmentFactory->create($order, $items); $shipment->register(); $shipment->save(); ..... } }
vendor/magento/module-sales/Model/Order/ShipmentFactory.php:74
class ShipmentFactory { /** * Creates shipment instance with specified parameters. */ public function create(\Magento\Sales\Model\Order $order, array $items = [], $tracks = null) { $shipment = $this->prepareItems($this->converter->toShipment($order), $order, $items); ..... return $shipment; } }
Frontend
The module does not provide any functionality for the storefront.