Skip to content

Commit 64ff4e9

Browse files
committed
Merge branch 'develop'
2 parents 9118a69 + 3fcdf16 commit 64ff4e9

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

classes/APIRoutes.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,15 @@ public static final function getRoutes(): array
284284
'module' => 'binshopsrest'
285285
]
286286
],
287+
'module-binshopsrest-emailsubscription' => [
288+
'rule' => 'rest/emailsubscription',
289+
'keywords' => [],
290+
'controller' => 'emailsubscription',
291+
'params' => [
292+
'fc' => 'module',
293+
'module' => 'binshopsrest'
294+
]
295+
],
287296
];
288297
}
289298
}

controllers/front/categoryproducts.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ protected function processGetRequest()
103103
'facets' => $facets
104104
];
105105

106+
if (Tools::getValue('with_category_tree')){
107+
$this->context->cookie->last_visited_category = $id_category;
108+
$categoryTreeModule = Module::getInstanceByName('ps_categorytree');
109+
$categoryTreeVariables = $categoryTreeModule->getWidgetVariables();
110+
$psdata['categories'] = $categoryTreeVariables['categories'];
111+
}
112+
106113
$this->ajaxRender(json_encode([
107114
'code' => 200,
108115
'success' => true,
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
/**
3+
* BINSHOPS
4+
*
5+
* @author BINSHOPS
6+
* @copyright BINSHOPS
7+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
8+
* Best In Shops eCommerce Solutions Inc.
9+
*
10+
*/
11+
12+
require_once dirname(__FILE__) . '/../AbstractRESTController.php';
13+
14+
class BinshopsrestEmailsubscriptionModuleFrontController extends AbstractRESTController
15+
{
16+
17+
protected function processGetRequest()
18+
{
19+
$conditions = Configuration::get('NW_CONDITIONS', $this->context->language->id);
20+
21+
$this->ajaxRender(json_encode([
22+
'success' => true,
23+
'code' => 200,
24+
'psdata' => $conditions,
25+
'message' => 'success'
26+
]));
27+
die;
28+
}
29+
30+
protected function processPostRequest()
31+
{
32+
$ps_emailsubscription = Module::getInstanceByName('ps_emailsubscription');
33+
$email = Tools::getValue('email', '');
34+
35+
if ($ps_emailsubscription->isNewsletterRegistered($email) === 1 || $ps_emailsubscription->isNewsletterRegistered($email) === 2){
36+
$this->ajaxRender(json_encode([
37+
'success' => false,
38+
'code' => 301,
39+
'message' => 'This email is already registered'
40+
]));
41+
die;
42+
}
43+
44+
if ($this->registerGuest($email)) {
45+
$this->ajaxRender(json_encode([
46+
'success' => true,
47+
'code' => 200,
48+
'message' => 'success'
49+
]));
50+
die;
51+
52+
} elseif ($ps_emailsubscription->valid) {
53+
$this->ajaxRender(json_encode([
54+
'success' => false,
55+
'code' => 300,
56+
'message' => 'failure'
57+
]));
58+
die;
59+
}
60+
}
61+
62+
protected function processPutRequest()
63+
{
64+
$this->ajaxRender(json_encode([
65+
'success' => true,
66+
'message' => 'put not supported on this path'
67+
]));
68+
die;
69+
}
70+
71+
protected function processDeleteRequest()
72+
{
73+
$this->ajaxRender(json_encode([
74+
'success' => true,
75+
'message' => 'delete not supported on this path'
76+
]));
77+
die;
78+
}
79+
80+
protected function registerGuest($email, $active = true)
81+
{
82+
$sql = 'INSERT INTO ' . _DB_PREFIX_ . 'emailsubscription (id_shop, id_shop_group, email, newsletter_date_add, ip_registration_newsletter, http_referer, active, id_lang)
83+
VALUES
84+
(' . $this->context->shop->id . ',
85+
' . $this->context->shop->id_shop_group . ',
86+
\'' . pSQL($email) . '\',
87+
NOW(),
88+
\'' . pSQL(Tools::getRemoteAddr()) . '\',
89+
(
90+
SELECT c.http_referer
91+
FROM ' . _DB_PREFIX_ . 'connections c
92+
WHERE c.id_guest = ' . (int) $this->context->customer->id . '
93+
ORDER BY c.date_add DESC LIMIT 1
94+
),
95+
' . (int) $active . ',
96+
' . $this->context->language->id . '
97+
)';
98+
99+
return Db::getInstance()->execute($sql);
100+
}
101+
}

0 commit comments

Comments
 (0)