diff --git a/classes/Hook/HookActionValidateOrder.php b/classes/Hook/HookActionValidateOrder.php index 284a23e..cd27092 100644 --- a/classes/Hook/HookActionValidateOrder.php +++ b/classes/Hook/HookActionValidateOrder.php @@ -53,8 +53,10 @@ public function __construct(Ps_Googleanalytics $module, Context $context) */ public function run() { - // Check if we are creating backoffice order - if ($this->context->controller->controller_name != 'AdminOrders' && $this->context->controller->controller_name != 'Admin') { + // Check if we are creating backoffice order, we are only launching this hook when creating backoffice order + // For FO purposes, we use displayOrderConfirmation. + if (empty($this->context->controller->controller_name) + || !in_array($this->context->controller->controller_name, ['AdminOrders', 'Admin'])) { return; } diff --git a/config.xml b/config.xml index 1ff7523..9fc803a 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_googleanalytics - + diff --git a/controllers/admin/AdminGanalyticsAjax.php b/controllers/admin/AdminGanalyticsAjax.php index 2deb985..1ec6dbc 100644 --- a/controllers/admin/AdminGanalyticsAjax.php +++ b/controllers/admin/AdminGanalyticsAjax.php @@ -31,9 +31,11 @@ public function init() if (Validate::isLoadedObject($order) && (isset($this->context->employee->id) && $this->context->employee->id)) { (new GanalyticsRepository())->markOrderAsSent((int) $orderId); - $this->ajaxDie('OK'); + $this->ajaxRender('OK'); + exit; } - $this->ajaxDie('KO'); + $this->ajaxRender('KO'); + exit; } } diff --git a/controllers/front/ajax.php b/controllers/front/ajax.php index 4c104e5..c77698e 100644 --- a/controllers/front/ajax.php +++ b/controllers/front/ajax.php @@ -35,11 +35,13 @@ public function initContent() $order = new Order($orderId); if (!Validate::isLoadedObject($order) || $order->id_customer != (int) Tools::getValue('customer')) { - $this->ajaxDie('KO'); + $this->ajaxRender('KO'); + exit; } (new GanalyticsRepository())->markOrderAsSent((int) $orderId); - $this->ajaxDie('OK'); + $this->ajaxRender('OK'); + exit; } } diff --git a/ps_googleanalytics.php b/ps_googleanalytics.php index 394f04c..bc9a711 100644 --- a/ps_googleanalytics.php +++ b/ps_googleanalytics.php @@ -47,7 +47,7 @@ public function __construct() { $this->name = 'ps_googleanalytics'; $this->tab = 'analytics_stats'; - $this->version = '5.0.0'; + $this->version = '5.0.1'; $this->ps_versions_compliancy = ['min' => '1.7.7', 'max' => _PS_VERSION_]; $this->author = 'PrestaShop'; $this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8'; diff --git a/tests/phpstan/phpstan-1.7.7.neon b/tests/phpstan/phpstan-1.7.7.neon index 364a960..caca568 100644 --- a/tests/phpstan/phpstan-1.7.7.neon +++ b/tests/phpstan/phpstan-1.7.7.neon @@ -6,3 +6,4 @@ parameters: - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' + - '#Parameter \#1 \$value of method ControllerCore::ajaxRender\(\) expects null, string given.#'