Skip to content

Commit

Permalink
Merge pull request #147 from mailjet/DE-1242-hook-deprecated-ps-8
Browse files Browse the repository at this point in the history
Deprecated hook
  • Loading branch information
oleksandr-mykhailenko committed Feb 19, 2024
2 parents 690a042 + 194ffa5 commit 3ab1399
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config.xml
Expand Up @@ -2,10 +2,10 @@
<module>
<name>mailjet</name>
<displayName><![CDATA[Mailjet]]></displayName>
<version><![CDATA[3.6.0]]></version>
<version><![CDATA[3.6.2]]></version>
<description><![CDATA[Create contact lists and client segment groups, drag-n-drop newsletters, define client re-engagement triggers, follow and analyze all email user interaction, minimize negative user engagement events(blocked, unsubs and spam) and optimise deliverability and revenue generation. Get started today with 6000 free emails per month.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[advertising_marketing]]></tab>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
</module>
</module>
32 changes: 31 additions & 1 deletion mailjet.php
Expand Up @@ -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()
Expand All @@ -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')
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3ab1399

Please sign in to comment.