Skip to content

Commit 90afb05

Browse files
author
Pablo Borowicz
authored
Merge pull request #114 from Progi1984/issue27911
2 parents 8f32c52 + 7d90bb1 commit 90afb05

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

classes/Hook/HookActionProductCancel.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Context;
2424
use OrderDetail;
2525
use Ps_Googleanalytics;
26-
use Tools;
2726

2827
class HookActionProductCancel implements HookInterface
2928
{
@@ -44,20 +43,19 @@ public function __construct(Ps_Googleanalytics $module, Context $context)
4443
*/
4544
public function run()
4645
{
47-
$quantityRefunded = Tools::getValue('cancelQuantity');
48-
$gaScripts = '';
49-
50-
foreach ($quantityRefunded as $orderDetailId => $quantity) {
51-
// Display GA refund product
52-
$orderDetail = new OrderDetail($orderDetailId);
53-
$gaScripts .= 'MBG.add(' . json_encode(
54-
[
55-
'id' => empty($orderDetail->product_attribute_id) ? $orderDetail->product_id : $orderDetail->product_id . '-' . $orderDetail->product_attribute_id,
56-
'quantity' => $quantity,
57-
])
58-
. ');';
46+
if (!isset($this->params['id_order_detail']) || !isset($this->params['cancel_quantity'])) {
47+
return;
5948
}
6049

50+
// Display GA refund product
51+
$orderDetail = new OrderDetail($this->params['id_order_detail']);
52+
$gaScripts = 'MBG.add(' . json_encode(
53+
[
54+
'id' => empty($orderDetail->product_attribute_id) ? $orderDetail->product_id : $orderDetail->product_id . '-' . $orderDetail->product_attribute_id,
55+
'quantity' => $this->params['cancel_quantity'],
56+
])
57+
. ');';
58+
6159
$this->context->cookie->__set(
6260
'ga_admin_refund',
6361
$gaScripts . 'MBG.refundByProduct(' . json_encode(['id' => $this->params['order']->id]) . ');'

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<module>
33
<name>ps_googleanalytics</name>
44
<displayName><![CDATA[Google Analytics]]></displayName>
5-
<version><![CDATA[4.1.1]]></version>
5+
<version><![CDATA[4.1.2]]></version>
66
<description><![CDATA[Gain clear insights into important metrics about your customers, using Google Analytics]]></description>
77
<author><![CDATA[PrestaShop]]></author>
88
<tab><![CDATA[analytics_stats]]></tab>

ps_googleanalytics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct()
5454
{
5555
$this->name = 'ps_googleanalytics';
5656
$this->tab = 'analytics_stats';
57-
$this->version = '4.1.1';
57+
$this->version = '4.1.2';
5858
$this->ps_versions_compliancy = ['min' => '1.6', 'max' => _PS_VERSION_];
5959
$this->author = 'PrestaShop';
6060
$this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8';

0 commit comments

Comments
 (0)