Skip to content

Commit 3264cac

Browse files
committed
Refactor hookActionCustomerAccountAdd in ps_emailsubscription
1 parent cacf793 commit 3264cac

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

ps_emailsubscription.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -951,25 +951,20 @@ public function hookActionCustomerAccountAdd($params)
951951
if (empty($params['newCustomer'])) {
952952
return false;
953953
}
954+
954955
$id_shop = $params['newCustomer']->id_shop;
955956
$email = $params['newCustomer']->email;
956-
$newsletter = $params['newCustomer']->newsletter;
957-
if (Validate::isEmail($email)) {
958-
if ($params['newCustomer']->newsletter && $code = Configuration::get('NW_VOUCHER_CODE')) {
959-
$this->sendVoucher($email, $code);
960-
}
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-
}
957+
958+
if (!Validate::isEmail($email)) {
959+
return false;
964960
}
965961

966-
if ($newsletter) {
967-
if (Configuration::get('NW_CONFIRMATION_EMAIL')) {// send confirmation email
968-
$this->sendConfirmationEmail($params['newCustomer']->email);
969-
}
970-
if ($code = Configuration::get('NW_VOUCHER_CODE')) {// send voucher
971-
$this->sendVoucher($params['newCustomer']->email, $code);
962+
if ($params['newCustomer']->newsletter) {
963+
if ($code = Configuration::get('NW_VOUCHER_CODE')) {
964+
$this->sendVoucher($email, $code);
972965
}
966+
967+
return (bool) Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'emailsubscription WHERE id_shop=' . (int) $id_shop . ' AND email=\'' . pSQL($email) . "'");
973968
}
974969

975970
return true;

0 commit comments

Comments
 (0)