Skip to content

Commit 3adf470

Browse files
authored
Merge pull request #136 from PrestaShop/dev
Release 4.2.1
2 parents 85ebb57 + aa5edf7 commit 3adf470

7 files changed

Lines changed: 38 additions & 8 deletions

File tree

classes/Form/ConfigurationForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function generate()
170170
'type' => 'select',
171171
'label' => $this->module->trans('Canceled order states', [], 'Modules.GAnalytics.Admin'),
172172
'name' => 'GA_CANCELLED_STATES',
173-
'desc' => $this->module->trans('Choose order states, in which you consider the given order canceled. This will usually be the default "Canceled" state, but some shops may have extra states like "Returned" etc.', [], 'Modules.GAnalytics.Admin'),
173+
'desc' => $this->module->trans('Choose order states in which you consider the given order canceled. This will usually be the default "Canceled" state, but some stores may have extra states like "Returned", etc.', [], 'Modules.GAnalytics.Admin'),
174174
'class' => 'chosen',
175175
'multiple' => true,
176176
'options' => [

classes/Hook/HookActionCarrierProcess.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,18 @@ public function setParams($params)
7171
$this->params = $params;
7272
}
7373

74-
protected function getUniversalAnalytics(string $carrierName)
74+
/**
75+
* @param string $carrierName
76+
*/
77+
protected function getUniversalAnalytics($carrierName)
7578
{
7679
return 'MBG.addCheckoutOption(2,\'' . $carrierName . '\');';
7780
}
7881

79-
protected function getGoogleAnalytics4(string $carrierName)
82+
/**
83+
* @param string $carrierName
84+
*/
85+
protected function getGoogleAnalytics4($carrierName)
8086
{
8187
$eventData = [
8288
'currency' => $this->context->currency->iso_code,

classes/Hook/HookActionOrderStatusPostUpdate.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,17 @@ public function setParams($params)
9999
$this->params = $params;
100100
}
101101

102+
/**
103+
* @param int $idOrder
104+
*/
102105
protected function getUniversalAnalytics($idOrder)
103106
{
104107
return 'MBG.refundByOrderId(' . json_encode(['id' => $idOrder]) . ');';
105108
}
106109

110+
/**
111+
* @param int $idOrder
112+
*/
107113
protected function getGoogleAnalytics4($idOrder)
108114
{
109115
$eventData = [

classes/Hook/HookActionProductCancel.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Context;
2525
use OrderDetail;
2626
use Ps_Googleanalytics;
27+
use Validate;
2728

2829
class HookActionProductCancel implements HookInterface
2930
{
@@ -57,6 +58,12 @@ public function run()
5758
// Display GA refund product
5859
$orderDetail = new OrderDetail($this->params['id_order_detail']);
5960

61+
// Check if the hook provided us with a valid existing ID of order detail.
62+
// An example are automatic tests, which do not provide it unfortunately.
63+
if (!Validate::isLoadedObject($orderDetail)) {
64+
return;
65+
}
66+
6067
$idProduct = empty($orderDetail->product_attribute_id) ? $orderDetail->product_id : $orderDetail->product_id . '-' . $orderDetail->product_attribute_id;
6168
if ((bool) Configuration::get('GA_V4_ENABLED')) {
6269
$js = $this->getGoogleAnalytics4(
@@ -86,7 +93,12 @@ public function setParams($params)
8693
$this->params = $params;
8794
}
8895

89-
protected function getUniversalAnalytics(int $idOrder, string $idProduct, float $quantity)
96+
/**
97+
* @param int $idOrder
98+
* @param string $idProduct
99+
* @param float $quantity
100+
*/
101+
protected function getUniversalAnalytics($idOrder, $idProduct, $quantity)
90102
{
91103
$js = 'MBG.add(' . json_encode(
92104
[
@@ -99,7 +111,13 @@ protected function getUniversalAnalytics(int $idOrder, string $idProduct, float
99111
return $js;
100112
}
101113

102-
protected function getGoogleAnalytics4(int $idOrder, string $idProduct, float $quantity, string $nameProduct)
114+
/**
115+
* @param int $idOrder
116+
* @param string $idProduct
117+
* @param float $quantity
118+
* @param string $nameProduct
119+
*/
120+
protected function getGoogleAnalytics4($idOrder, $idProduct, $quantity, $nameProduct)
103121
{
104122
$eventData = [
105123
'transaction_id' => (int) $idOrder,

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.2.0]]></version>
5+
<version><![CDATA[4.2.1]]></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.2.0';
57+
$this->version = '4.2.1';
5858
$this->ps_versions_compliancy = ['min' => '1.6', 'max' => _PS_VERSION_];
5959
$this->author = 'PrestaShop';
6060
$this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8';

views/templates/hook/ps_googleanalytics.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
'config',
2828
'{$gaAccountId|escape:'htmlall':'UTF-8'}',
2929
{ldelim}
30-
'debug_mode':true
30+
'debug_mode':false
3131
{if $gaAnonymizeEnabled}, 'anonymize_ip': true{/if}
3232
{if $userId && !$backOffice}, 'user_id': '{$userId|escape:'htmlall':'UTF-8'}'{/if}
3333
{if $backOffice && !$trackBackOffice}, 'non_interaction': true, 'send_page_view': false{/if}

0 commit comments

Comments
 (0)