You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (isset(Hook::$executed_hooks[$confirmation_hook_id])) {
389
428
$this->eligible = 1;
@@ -671,6 +710,38 @@ protected function _runJs($js_code, $backoffice = 0)
671
710
}
672
711
}
673
712
713
+
/**
714
+
* Manage data
715
+
* @param string $action "R" read data from DB, "W" write data, "A" append data, D" delete data
716
+
* @return array dans le cas du R, sinon true
717
+
*/
718
+
protectedfunction_manageData($data, $action)
719
+
{
720
+
if ($action == 'R') {
721
+
$dataretour = Db::getInstance()->getValue('SELECT data FROM `'._DB_PREFIX_.'ganalytics_data` WHERE id_cart = \''.(int)$this->context->cart->id.'\' AND id_shop = \''.(int)$this->context->shop->id.'\'');
722
+
if ($dataretour === false)
723
+
returnarray();
724
+
else
725
+
returnjson_decode($dataretour,true);
726
+
}
727
+
if ($action == 'W') {
728
+
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($data).'\') ON DUPLICATE KEY UPDATE data =\''.json_encode($data).'\' ;');
729
+
}
730
+
if ($action == 'A') {
731
+
$dataretour = Db::getInstance()->getValue('SELECT data FROM `'._DB_PREFIX_.'ganalytics_data` WHERE id_cart = \''.(int)$this->context->cart->id.'\' AND id_shop = \''.(int)$this->context->shop->id.'\'');
732
+
if ($dataretour === false)
733
+
$datanew = array($data);
734
+
else {
735
+
$datanew = json_decode($dataretour,true);
736
+
$datanew[] = $data;
737
+
}
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).'\' ;');
739
+
}
740
+
if ($action == 'D') {
741
+
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.'\'');
742
+
}
743
+
}
744
+
674
745
/**
675
746
* Hook admin order to send transactions and refunds details
676
747
*/
@@ -808,11 +879,7 @@ public function hookactionCartSave()
0 commit comments