Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated hook #147

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config.xml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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