From c04c1998535a7e0e1e3e3ccedee2768861089208 Mon Sep 17 00:00:00 2001 From: Walter Bacchetti Date: Thu, 3 Oct 2019 14:50:18 +0200 Subject: [PATCH] Completed 'Initial order status change', introduced in v.1.2.7 --- Observer/ChangeOrderStatus.php | 51 ++++++++++++++++++++++++++++++++++ etc/events.xml | 5 ++++ 2 files changed, 56 insertions(+) create mode 100644 Observer/ChangeOrderStatus.php diff --git a/Observer/ChangeOrderStatus.php b/Observer/ChangeOrderStatus.php new file mode 100644 index 0000000..5498b24 --- /dev/null +++ b/Observer/ChangeOrderStatus.php @@ -0,0 +1,51 @@ +get('Magento\Framework\App\Config\ScopeConfigInterface'); + /** @var OrderInterface $order */ + $order = $observer->getEvent()->getOrder(); + + if ($order->getPayment()->getMethod() == static::CODE) { + $currentStatus = $order->getStatus(); + $customStatus = $_scopeConfig->getValue(static::XML_PATH_ORDER_STATUS); + if ($currentStatus != $customStatus) { + $order->setStatus($customStatus); + $order->save(); + } + } + } +} diff --git a/etc/events.xml b/etc/events.xml index 214c52e..468520f 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -7,4 +7,9 @@ instance="MSP\CashOnDelivery\Observer\SalesModelServiceQuoteSubmitBefore"/> + + + +