From 43e2b95f0ed98742db7a2e9e6d542b322b00e6ca Mon Sep 17 00:00:00 2001 From: "Paolo Cunti @codencode" Date: Sun, 7 Dec 2025 12:33:37 +0100 Subject: [PATCH 1/3] Refactor hookActionCustomerAccountAdd in ps_emailsubscription --- ps_emailsubscription.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/ps_emailsubscription.php b/ps_emailsubscription.php index 8de6d5d..21e3e63 100644 --- a/ps_emailsubscription.php +++ b/ps_emailsubscription.php @@ -964,25 +964,20 @@ public function hookActionCustomerAccountAdd($params) if (empty($params['newCustomer'])) { return false; } + $id_shop = $params['newCustomer']->id_shop; $email = $params['newCustomer']->email; - $newsletter = $params['newCustomer']->newsletter; - if (Validate::isEmail($email)) { - if ($params['newCustomer']->newsletter && $code = Configuration::get('NW_VOUCHER_CODE')) { - $this->sendVoucher($email, $code); - } - if ($params['newCustomer']->newsletter) { - return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'"); - } + + if (!Validate::isEmail($email)) { + return false; } - if ($newsletter) { - if (Configuration::get('NW_CONFIRMATION_EMAIL')) {// send confirmation email - $this->sendConfirmationEmail($params['newCustomer']->email); - } - if ($code = Configuration::get('NW_VOUCHER_CODE')) {// send voucher - $this->sendVoucher($params['newCustomer']->email, $code); + if ($params['newCustomer']->newsletter) { + if ($code = Configuration::get('NW_VOUCHER_CODE')) { + $this->sendVoucher($email, $code); } + + return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'"); } return true; From b4ba7f606cdf72143abec85d18ce0c5d841436de Mon Sep 17 00:00:00 2001 From: Codencode Date: Wed, 21 Jan 2026 12:49:28 +0100 Subject: [PATCH 2/3] refactor: improve emailsubscription DELETE query formatting --- ps_emailsubscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ps_emailsubscription.php b/ps_emailsubscription.php index 21e3e63..3d9a6c0 100644 --- a/ps_emailsubscription.php +++ b/ps_emailsubscription.php @@ -977,7 +977,7 @@ public function hookActionCustomerAccountAdd($params) $this->sendVoucher($email, $code); } - return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'"); + return Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'emailsubscription` WHERE id_shop = ' . (int) $id_shop . 'AND email = "' . pSQL($email) . '"'); } return true; From a0a8962ef838f4528e184af1ab54a9cdf91ec10f Mon Sep 17 00:00:00 2001 From: "Paolo Cunti @codencode" Date: Thu, 26 Mar 2026 21:37:37 +0100 Subject: [PATCH 3/3] Fix missing space in emailsubscription delete query --- ps_emailsubscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ps_emailsubscription.php b/ps_emailsubscription.php index 3d9a6c0..9738960 100644 --- a/ps_emailsubscription.php +++ b/ps_emailsubscription.php @@ -977,7 +977,7 @@ public function hookActionCustomerAccountAdd($params) $this->sendVoucher($email, $code); } - return Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'emailsubscription` WHERE id_shop = ' . (int) $id_shop . 'AND email = "' . pSQL($email) . '"'); + return Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'emailsubscription` WHERE id_shop = ' . (int) $id_shop . ' AND email = "' . pSQL($email) . '"'); } return true;