Skip to content

Commit 859208f

Browse files
[*] MO : Fix issue with hookactionCarrierProcess
1 parent 1dc9106 commit 859208f

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

ps_googleanalytics.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct()
4040
{
4141
$this->name = 'ps_googleanalytics';
4242
$this->tab = 'analytics_stats';
43-
$this->version = '3.1.0';
43+
$this->version = '3.1.1';
4444
$this->ps_versions_compliancy = array('min' => '1.7.0.0', 'max' => _PS_VERSION_);
4545
$this->author = 'PrestaShop';
4646
$this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8';
@@ -398,11 +398,16 @@ public function hookdisplayFooter()
398398
$this->filterable = 0;
399399

400400
foreach ($gacarts as $gacart) {
401-
if ($gacart['quantity'] > 0) {
402-
$ga_scripts .= 'MBG.addToCart('.json_encode($gacart).');';
403-
} elseif ($gacart['quantity'] < 0) {
404-
$gacart['quantity'] = abs($gacart['quantity']);
405-
$ga_scripts .= 'MBG.removeFromCart('.json_encode($gacart).');';
401+
if (isset($gacart['quantity']))
402+
{
403+
if ($gacart['quantity'] > 0) {
404+
$ga_scripts .= 'MBG.addToCart('.json_encode($gacart).');';
405+
} elseif ($gacart['quantity'] < 0) {
406+
$gacart['quantity'] = abs($gacart['quantity']);
407+
$ga_scripts .= 'MBG.removeFromCart('.json_encode($gacart).');';
408+
}
409+
} else {
410+
$ga_scripts .= $gacart;
406411
}
407412
}
408413
$gacarts = $this->_manageData("", "D");
@@ -735,7 +740,7 @@ protected function _manageData($data, $action)
735740
$datanew = json_decode($dataretour,true);
736741
$datanew[] = $data;
737742
}
738-
return Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'ganalytics_data` (id_cart, id_shop, data) VALUES(\''.(int)$this->context->cart->id.'\',\''.(int)$this->context->shop->id.'\',\''.json_encode($datanew).'\') ON DUPLICATE KEY UPDATE data =\''.serialize($datanew).'\' ;');
743+
return Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'ganalytics_data` (id_cart, id_shop, data) VALUES(\''.(int)$this->context->cart->id.'\',\''.(int)$this->context->shop->id.'\',\''.pSQL(json_encode($datanew)).'\') ON DUPLICATE KEY UPDATE data =\''.pSQL(json_encode($datanew)).'\' ;');
739744
}
740745
if ($action == 'D') {
741746
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'ganalytics_data` WHERE id_cart = \''.(int)$this->context->cart->id.'\' AND id_shop = \''.(int)$this->context->shop->id.'\'');

0 commit comments

Comments
 (0)