Skip to content

Commit c1e6737

Browse files
committed
Add new hook file
1 parent 8b5a36a commit c1e6737

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright since 2007 PrestaShop SA and Contributors
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
8+
* that is bundled with this package in the file LICENSE.md.
9+
* It is also available through the world-wide-web at this URL:
10+
* https://opensource.org/licenses/AFL-3.0
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@prestashop.com so we can send you a copy immediately.
14+
*
15+
* @author PrestaShop SA <contact@prestashop.com>
16+
* @copyright Since 2007 PrestaShop SA and Contributors
17+
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
18+
* International Registered Trademark & Property of PrestaShop SA
19+
*/
20+
21+
namespace PrestaShop\Module\Ps_Googleanalytics\Hooks;
22+
23+
use Context;
24+
use Ps_Googleanalytics;
25+
26+
class HookActionValidateOrder implements HookInterface
27+
{
28+
/**
29+
* @var Ps_Googleanalytics
30+
*/
31+
private $module;
32+
33+
/**
34+
* @var Context
35+
*/
36+
private $context;
37+
38+
/**
39+
* @var array
40+
*/
41+
private $params;
42+
43+
public function __construct(Ps_Googleanalytics $module, Context $context)
44+
{
45+
$this->module = $module;
46+
$this->context = $context;
47+
}
48+
49+
/**
50+
* run
51+
*
52+
* @return void
53+
*/
54+
public function run()
55+
{
56+
// Check if we are creating backoffice order
57+
if ($this->context->controller->controller_name != 'AdminOrders' && $this->context->controller->controller_name != 'Admin') {
58+
return;
59+
}
60+
61+
// Mark this ID to immediately display it on next page load
62+
if (!empty($this->context->cookie->__get('ga_admin_order'))) {
63+
$ga_admin_order = $this->context->cookie->__get('ga_admin_order') . "," . ($this->params['order'])->id;
64+
} else {
65+
$ga_admin_order = ($this->params['order'])->id;
66+
}
67+
$this->context->cookie->__set('ga_admin_order', $ga_admin_order);
68+
$this->context->cookie->write();
69+
}
70+
71+
/**
72+
* setParams
73+
*
74+
* @param array $params
75+
*/
76+
public function setParams($params)
77+
{
78+
$this->params = $params;
79+
}
80+
}

0 commit comments

Comments
 (0)