From 653a973b78b5331143fc480cdc4dd733f8563753 Mon Sep 17 00:00:00 2001 From: hekep <1901788+hekep@users.noreply.github.com> Date: Thu, 28 Feb 2019 15:27:09 +0200 Subject: [PATCH] Avoid duplicate orders in Google Analytics Avoid duplicate orders in Google Analytics --- ganalytics.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ganalytics.php b/ganalytics.php index 3470950..fff175c 100755 --- a/ganalytics.php +++ b/ganalytics.php @@ -326,8 +326,16 @@ public function hookOrderConfirmation($params) 'tax' => $order->total_paid_tax_incl - $order->total_paid_tax_excl, 'url' => $this->context->link->getModuleLink('ganalytics', 'ajax', array(), true), 'customer' => $order->id_customer); - $ga_scripts .= $this->addTransaction($order_products, $transaction); + Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'ganalytics` SET date_add = NOW(), sent = 1 ' + . ' WHERE id_order = ' .(int) $order->id + .' AND id_shop = \''.(int) $this->context->shop->id.'\' ' + .' AND sent = 0 ' + . ' '); + $affectedRows = Db::getInstance()->Affected_Rows(); + if ( $affectedRows == 1) { + $ga_scripts .= $this->addTransaction($order_products, $transaction); + } $this->js_state = 1; return $this->_runJs($ga_scripts); }