@@ -53,27 +53,31 @@ public function __construct(
5353
5454 public function execute (\Magento \Framework \Event \Observer $ observer )
5555 {
56- if (!$ this ->helper ->getConfigData ('active ' )) {
56+ /** @var Order $observerOrder */
57+ $ observerOrder = $ observer ->getEvent ()->getOrder ();
58+ if (!$ observerOrder || !$ observerOrder ->getId ()) {
5759 return ;
5860 }
5961
60- // Don't do anything when auto shipment is disabled.
61- if (! boolval ( $ this -> helper -> getConfigData ( ' usability/automation/shipment ' ))
62- || strval ( $ this ->helper ->getConfigData ('usability/automation/on_order_status ' )) === '' ) {
62+ $ storeId = $ observerOrder -> getStoreId ();
63+
64+ if (! $ this ->helper ->getConfigData ('active ' , $ storeId ) ) {
6365 return ;
6466 }
6567
66- // Only continue if the event trigger name matches
67- if ($ this ->helper ->getConfigData ('usability/automation/event_trigger ' ) !== $ observer ->getEvent ()->getName ()) {
68+ // Don't do anything when auto shipment is disabled.
69+ if (!boolval ($ this ->helper ->getConfigData ('usability/automation/shipment ' , $ storeId ))
70+ || strval ($ this ->helper ->getConfigData ('usability/automation/on_order_status ' , $ storeId )) === '' ) {
6871 return ;
6972 }
7073
71- $ observerOrder = $ observer -> getEvent ()-> getOrder ();
72- if (! $ observerOrder || ! $ observerOrder -> getId ()) {
74+ // Only continue if the event trigger name matches
75+ if ($ this -> helper -> getConfigData ( ' usability/automation/event_trigger ' , $ storeId ) !== $ observer -> getEvent ()-> getName ()) {
7376 return ;
7477 }
7578
76- if ($ observerOrder ->getStatus () !== $ this ->helper ->getConfigData ('usability/automation/on_order_status ' )) {
79+
80+ if ($ observerOrder ->getStatus () !== $ this ->helper ->getConfigData ('usability/automation/on_order_status ' , $ storeId )) {
7781 return ;
7882 }
7983 if (!$ observerOrder ->canShip () || $ observerOrder ->hasShipments () || $ observerOrder ->getShipmentsCollection ()->count () > 0 ) {
@@ -90,7 +94,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
9094 return ;
9195 }
9296
93- if (intval ($ this ->helper ->getConfigData ('usability/automation/shipment ' )) === YesNoDHL::OPTION_DHL && !$ this ->presetService ->exists ($ order )) {
97+ if (intval ($ this ->helper ->getConfigData ('usability/automation/shipment ' , $ storeId )) === YesNoDHL::OPTION_DHL && !$ this ->presetService ->exists ($ order )) {
9498 return ;
9599 }
96100
@@ -104,7 +108,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
104108
105109 $ shipment = $ this ->orderService ->createShipment ($ order ->getId ());
106110
107- if (boolval ($ this ->helper ->getConfigData ('usability/automation/print ' ))) {
111+ if (boolval ($ this ->helper ->getConfigData ('usability/automation/print ' , $ storeId ))) {
108112 // Reload shipment (not the shipment data in memory but from database with the newly created tracks) and send to printer
109113 $ shipment = $ this ->shipmentService ->getShipmentById ($ shipment ->getId ());
110114 $ labelIds = $ this ->labelService ->getShipmentLabelIds ($ shipment );
0 commit comments