Skip to content

Commit f50a787

Browse files
authored
Merge pull request PrestaShop#114 from Codencode/fix-38446-Problem-with-the-newsletter-subscription-module
2 parents 46ab8c9 + 9eab6e0 commit f50a787

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ps_emailsubscription.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,9 @@ public function hookActionCustomerAccountAdd($params)
958958
if ($params['newCustomer']->newsletter && $code = Configuration::get('NW_VOUCHER_CODE')) {
959959
$this->sendVoucher($email, $code);
960960
}
961-
962-
return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'");
961+
if ($params['newCustomer']->newsletter) {
962+
return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'");
963+
}
963964
}
964965

965966
if ($newsletter) {
@@ -978,6 +979,8 @@ public function hookActionObjectCustomerUpdateBefore($params)
978979
{
979980
$customer = new Customer($params['object']->id);
980981
$this->_origin_newsletter = (int) $customer->newsletter;
982+
983+
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $params['object']->id_shop . ' AND email=\'' . pSQL($params['object']->email) . "'");
981984
}
982985

983986
public function hookActionCustomerAccountUpdate($params)

0 commit comments

Comments
 (0)