diff --git a/config.xml b/config.xml index c4ce281..6d5b389 100644 --- a/config.xml +++ b/config.xml @@ -2,10 +2,10 @@ mailjet - + 1 1 - \ No newline at end of file + diff --git a/mailjet.php b/mailjet.php index fe23ccd..9c17eab 100644 --- a/mailjet.php +++ b/mailjet.php @@ -246,6 +246,11 @@ public function install() $this->createTriggers(); Configuration::updateValue('MJ_ALLEMAILS', 1); + $updateOrderHook = 'updateOrderStatus'; + if (version_compare(_PS_VERSION_, '8', '>=')) { + $updateOrderHook = 'actionOrderStatusUpdate'; + } + return ( parent::install() && $this->loadConfiguration() @@ -269,7 +274,7 @@ public function install() && $this->registerHook('orderReturn') && $this->registerHook('orderSlip') && $this->registerHook('registerGDPRConsent') - && $this->registerHook('updateOrderStatus') + && $this->registerHook($updateOrderHook) && $this->registerHook('updateQuantity') && $this->registerHook('actionNewsletterRegistrationAfter') && $this->registerHook('actionNewsletterRegistrationBefore') @@ -901,6 +906,31 @@ public function hookUpdateOrderStatus($params) return ''; } + + /** + * @param $params + * @return string + */ + public function hookActionOrderStatusUpdate($params) + { + if (isset($params['id_order'])) { + $sql = 'SELECT id_customer + FROM ' . _DB_PREFIX_ . 'orders + WHERE id_order = ' . (int)$params['id_order']; + + if (($id_customer = (int)Db::getInstance()->getValue($sql)) > 0) { + $this->checkAutoAssignment($id_customer); + } + } elseif (isset($params['cart'])) { + $cart = $params['cart']; + if ($cart instanceof Cart && isset($cart->id_customer)) { + $this->checkAutoAssignment((int)$cart->id_customer); + } + } + + return ''; + } + public function hookOrderSlip($params) { return $this->hookUpdateOrderStatus($params);