...
The module adds the possibility to enable auto invoicing and auto shipping for orders.
Table of Contents | ||||
---|---|---|---|---|
|
Installation
Info |
---|
This module is optional. |
...
Admin settings for the module are placed in Stores -> Configuration -> Sales -> Auto order completion
...
Settings:
Setting name
Value
Field |
---|
Options | Comment | |
---|---|---|
Enable auto invoicing | Yes/No | Default value: No |
Enable auto shipping | Yes/No | Default value: No |
Backend
Note |
---|
Add documentation for BE code |
Command for complete Orders
Code Block |
---|
bin/magento order:complete |
vendor/creativestyle/magesuite-auto-order-completion/Console/Command/CompleteOrders.php:27
Code Block |
---|
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
Code Block |
---|
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
Code Block |
---|
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;
}
} |
Invoice Creator
vendor/creativestyle/magesuite-auto-order-completion/Service/InvoiceCreator.php:37
Code Block |
---|
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
Code Block |
---|
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;
}
} |
Shipment Creator
vendor/creativestyle/magesuite-auto-order-completion/Service/ShipmentCreator.php:25
Code Block |
---|
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
Code Block | ||
---|---|---|
| ||
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.