Skip to content

Commit f6168ac

Browse files
committed
Fix translation domains, bump compatibility
1 parent 12d5b7c commit f6168ac

5 files changed

Lines changed: 45 additions & 103 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Enhanced Ecommerce must be enabled in Google Analytics settings for full functio
2121

2222
PrestaShop modules are open-source extensions to the PrestaShop e-commerce solution. Everyone is welcome and even encouraged to contribute with their own improvements.
2323

24-
Google Analytics is compatible with all versions of PrestaShop 8, 1.7 and 1.6.
24+
Google Analytics is compatible with PrestaShop 1.7.6 and newer.
2525

2626
### Requirements
2727

classes/Form/ConfigurationForm.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -70,107 +70,107 @@ public function generate()
7070
$helper->submit_action = 'submit' . $this->module->name;
7171
$helper->toolbar_btn = [
7272
'save' => [
73-
'desc' => $this->module->trans('Save', [], 'Modules.GAnalytics.Admin'),
73+
'desc' => $this->module->trans('Save', [], 'Modules.Googleanalytics.Admin'),
7474
'href' => AdminController::$currentIndex . '&configure=' . $this->module->name . '&save=' . $this->module->name .
7575
'&token=' . $helper->token,
7676
],
7777
'back' => [
7878
'href' => AdminController::$currentIndex . '&token=' . $helper->token,
79-
'desc' => $this->module->trans('Back to list', [], 'Modules.GAnalytics.Admin'),
79+
'desc' => $this->module->trans('Back to list', [], 'Modules.Googleanalytics.Admin'),
8080
],
8181
];
8282

8383
$fields_form = [];
8484
// Init Fields form array
8585
$fields_form[0]['form'] = [
8686
'legend' => [
87-
'title' => $this->module->trans('Settings', [], 'Modules.GAnalytics.Admin'),
87+
'title' => $this->module->trans('Settings', [], 'Modules.Googleanalytics.Admin'),
8888
],
8989
'input' => [
9090
[
9191
'type' => 'switch',
92-
'label' => $this->module->trans('Enable Google Analytics 4', [], 'Modules.GAnalytics.Admin'),
92+
'label' => $this->module->trans('Enable Google Analytics 4', [], 'Modules.Googleanalytics.Admin'),
9393
'name' => 'GA_V4_ENABLED',
9494
'values' => [
9595
[
9696
'id' => 'GA_V4_ENABLED',
9797
'value' => 1,
98-
'label' => $this->module->trans('Yes', [], 'Modules.GAnalytics.Admin'),
98+
'label' => $this->module->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
9999
],
100100
[
101101
'id' => 'GA_V4_ENABLED',
102102
'value' => 0,
103-
'label' => $this->module->trans('No', [], 'Modules.GAnalytics.Admin'),
103+
'label' => $this->module->trans('No', [], 'Modules.Googleanalytics.Admin'),
104104
],
105105
],
106-
'desc' => $this->module->trans('Universal analytics will stop processing data on July 1, 2023. We recommend switching to Google Analytics 4 as soon as possible.', [], 'Modules.GAnalytics.Admin'),
106+
'desc' => $this->module->trans('Universal analytics will stop processing data on July 1, 2023. We recommend switching to Google Analytics 4 as soon as possible.', [], 'Modules.Googleanalytics.Admin'),
107107
],
108108
[
109109
'type' => 'text',
110-
'label' => $this->module->trans('Google Analytics Tracking ID', [], 'Modules.GAnalytics.Admin'),
110+
'label' => $this->module->trans('Google Analytics Tracking ID', [], 'Modules.Googleanalytics.Admin'),
111111
'name' => 'GA_ACCOUNT_ID',
112112
'size' => 20,
113113
'required' => true,
114-
'desc' => $this->module->trans('This information is available in your Google Analytics account. GA4 tracking ID starts with "G-", Universal Analytics with "UA-".', [], 'Modules.GAnalytics.Admin'),
114+
'desc' => $this->module->trans('This information is available in your Google Analytics account. GA4 tracking ID starts with "G-", Universal Analytics with "UA-".', [], 'Modules.Googleanalytics.Admin'),
115115
],
116116
[
117117
'type' => 'switch',
118-
'label' => $this->module->trans('Enable User ID tracking', [], 'Modules.GAnalytics.Admin'),
118+
'label' => $this->module->trans('Enable User ID tracking', [], 'Modules.Googleanalytics.Admin'),
119119
'name' => 'GA_USERID_ENABLED',
120120
'values' => [
121121
[
122122
'id' => 'ga_userid_enabled',
123123
'value' => 1,
124-
'label' => $this->module->trans('Yes', [], 'Modules.GAnalytics.Admin'),
124+
'label' => $this->module->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
125125
],
126126
[
127127
'id' => 'ga_userid_disabled',
128128
'value' => 0,
129-
'label' => $this->module->trans('No', [], 'Modules.GAnalytics.Admin'),
129+
'label' => $this->module->trans('No', [], 'Modules.Googleanalytics.Admin'),
130130
],
131131
],
132132
],
133133
[
134134
'type' => 'switch',
135-
'label' => $this->module->trans('Anonymize IP', [], 'Modules.GAnalytics.Admin'),
135+
'label' => $this->module->trans('Anonymize IP', [], 'Modules.Googleanalytics.Admin'),
136136
'name' => 'GA_ANONYMIZE_ENABLED',
137-
'hint' => $this->module->trans('Use this option to anonymize the visitor’s IP to comply with data privacy laws in some countries', [], 'Modules.GAnalytics.Admin'),
137+
'hint' => $this->module->trans('Use this option to anonymize the visitor’s IP to comply with data privacy laws in some countries', [], 'Modules.Googleanalytics.Admin'),
138138
'values' => [
139139
[
140140
'id' => 'ga_anonymize_enabled',
141141
'value' => 1,
142-
'label' => $this->module->trans('Yes', [], 'Modules.GAnalytics.Admin'),
142+
'label' => $this->module->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
143143
],
144144
[
145145
'id' => 'ga_anonymize_disabled',
146146
'value' => 0,
147-
'label' => $this->module->trans('No', [], 'Modules.GAnalytics.Admin'),
147+
'label' => $this->module->trans('No', [], 'Modules.Googleanalytics.Admin'),
148148
],
149149
],
150150
],
151151
[
152152
'type' => 'switch',
153-
'label' => $this->module->trans('Enable Back Office Tracking', [], 'Modules.GAnalytics.Admin'),
153+
'label' => $this->module->trans('Enable Back Office Tracking', [], 'Modules.Googleanalytics.Admin'),
154154
'name' => 'GA_TRACK_BACKOFFICE_ENABLED',
155-
'hint' => $this->module->trans('Use this option to enable the tracking inside the Back Office', [], 'Modules.GAnalytics.Admin'),
155+
'hint' => $this->module->trans('Use this option to enable the tracking inside the Back Office', [], 'Modules.Googleanalytics.Admin'),
156156
'values' => [
157157
[
158158
'id' => 'ga_track_backoffice',
159159
'value' => 1,
160-
'label' => $this->module->trans('Yes', [], 'Modules.GAnalytics.Admin'),
160+
'label' => $this->module->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
161161
],
162162
[
163163
'id' => 'ga_do_not_track_backoffice',
164164
'value' => 0,
165-
'label' => $this->module->trans('No', [], 'Modules.GAnalytics.Admin'),
165+
'label' => $this->module->trans('No', [], 'Modules.Googleanalytics.Admin'),
166166
],
167167
],
168168
],
169169
[
170170
'type' => 'select',
171-
'label' => $this->module->trans('Canceled order states', [], 'Modules.GAnalytics.Admin'),
171+
'label' => $this->module->trans('Canceled order states', [], 'Modules.Googleanalytics.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 stores 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.Googleanalytics.Admin'),
174174
'class' => 'chosen',
175175
'multiple' => true,
176176
'options' => [
@@ -181,25 +181,25 @@ public function generate()
181181
],
182182
],
183183
'submit' => [
184-
'title' => $this->module->trans('Save', [], 'Modules.GAnalytics.Admin'),
184+
'title' => $this->module->trans('Save', [], 'Modules.Googleanalytics.Admin'),
185185
],
186186
];
187187

188188
if ($is_multistore_active) {
189189
$fields_form[0]['form']['input'][] = [
190190
'type' => 'switch',
191-
'label' => $this->module->trans('Enable Cross-Domain tracking', [], 'Modules.GAnalytics.Admin'),
191+
'label' => $this->module->trans('Enable Cross-Domain tracking', [], 'Modules.Googleanalytics.Admin'),
192192
'name' => 'GA_CROSSDOMAIN_ENABLED',
193193
'values' => [
194194
[
195195
'id' => 'ga_crossdomain_enabled',
196196
'value' => 1,
197-
'label' => $this->module->trans('Yes', [], 'Modules.GAnalytics.Admin'),
197+
'label' => $this->module->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
198198
],
199199
[
200200
'id' => 'ga_crossdomain_disabled',
201201
'value' => 0,
202-
'label' => $this->module->trans('No', [], 'Modules.GAnalytics.Admin'),
202+
'label' => $this->module->trans('No', [], 'Modules.Googleanalytics.Admin'),
203203
],
204204
],
205205
];
@@ -266,6 +266,6 @@ public function treat()
266266
Configuration::updateValue('GA_CANCELLED_STATES', json_encode($gaCancelledStates));
267267
}
268268

269-
return $this->module->displayConfirmation($this->module->trans('Settings updated successfully.', [], 'Modules.GAnalytics.Admin'));
269+
return $this->module->displayConfirmation($this->module->trans('Settings updated successfully.', [], 'Modules.Googleanalytics.Admin'));
270270
}
271271
}

classes/Hook/HookDisplayOrderConfirmation.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ public function __construct(Ps_Googleanalytics $module, Context $context)
4949
*/
5050
public function run()
5151
{
52-
if (true === $this->module->psVersionIs17) {
53-
$order = $this->params['order'];
54-
} else {
55-
$order = $this->params['objOrder'];
56-
}
52+
$order = $this->params['order'];
5753

5854
if (Validate::isLoadedObject($order) && $order->getCurrentState() != (int) Configuration::get('PS_OS_ERROR')) {
5955
$ganalyticsRepository = new GanalyticsRepository();

ps_googleanalytics.php

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,27 @@
2828

2929
class Ps_Googleanalytics extends Module
3030
{
31-
/**
32-
* @var string Name of the module running on PS 1.6.x. Used for data migration.
33-
*/
34-
const PS_16_EQUIVALENT_MODULE = 'ganalytics';
35-
36-
public $name;
37-
public $tab;
38-
public $version;
39-
public $ps_versions_compliancy;
40-
public $author;
41-
public $module_key;
42-
public $bootstrap;
43-
public $displayName;
44-
public $description;
45-
public $confirmUninstall;
4631
public $eligible = 0;
4732
public $filterable = 1;
4833
public $products = [];
4934
public $_debug = 0;
50-
public $psVersionIs17;
5135
private $tools = null;
5236

5337
public function __construct()
5438
{
5539
$this->name = 'ps_googleanalytics';
5640
$this->tab = 'analytics_stats';
5741
$this->version = '4.2.2';
58-
$this->ps_versions_compliancy = ['min' => '1.6', 'max' => _PS_VERSION_];
42+
$this->ps_versions_compliancy = ['min' => '1.7.6', 'max' => _PS_VERSION_];
5943
$this->author = 'PrestaShop';
6044
$this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8';
6145
$this->bootstrap = true;
6246

6347
parent::__construct();
6448

65-
$this->displayName = $this->trans('Google Analytics', [], 'Modules.GAnalytics.Admin');
66-
$this->description = $this->trans('Gain clear insights into important metrics about your customers, using Google Analytics', [], 'Modules.GAnalytics.Admin');
67-
$this->confirmUninstall = $this->trans('Are you sure you want to uninstall Google Analytics? You will lose all the data related to this module.', [], 'Modules.GAnalytics.Admin');
68-
$this->psVersionIs17 = (bool) version_compare(_PS_VERSION_, '1.7', '>=');
49+
$this->displayName = $this->trans('Google Analytics', [], 'Modules.Googleanalytics.Admin');
50+
$this->description = $this->trans('Gain clear insights into important metrics about your customers, using Google Analytics', [], 'Modules.Googleanalytics.Admin');
51+
$this->confirmUninstall = $this->trans('Are you sure you want to uninstall Google Analytics? You will lose all the data related to this module.', [], 'Modules.Googleanalytics.Admin');
6952
}
7053

7154
/**
@@ -107,28 +90,11 @@ public function hookDisplayOrderConfirmation($params)
10790
}
10891

10992
/**
110-
* Footer hook for 1.6
111-
* This function is run to load JS script for standards actions such as product clicks
112-
*/
113-
public function hookDisplayFooter()
114-
{
115-
if ($this->psVersionIs17) {
116-
return;
117-
}
118-
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayFooter($this, $this->context);
119-
120-
return $hook->run();
121-
}
122-
123-
/**
124-
* Footer hook for 1.7
93+
* Footer hook
12594
* This function is run to load JS script for standards actions such as product clicks
12695
*/
12796
public function hookDisplayBeforeBodyClosingTag()
12897
{
129-
if (!$this->psVersionIs17) {
130-
return;
131-
}
13298
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayFooter($this, $this->context);
13399

134100
return $hook->run();
@@ -232,11 +198,8 @@ protected function _debugLog($function, $log)
232198
*/
233199
public function install()
234200
{
235-
$moduleHandler = new PrestaShop\Module\Ps_Googleanalytics\Handler\ModuleHandler();
236201
$database = new PrestaShop\Module\Ps_Googleanalytics\Database\Install($this);
237202

238-
$moduleHandler->uninstallModule(self::PS_16_EQUIVALENT_MODULE);
239-
240203
return parent::install() &&
241204
$database->registerHooks() &&
242205
$database->setDefaultConfiguration() &&
@@ -257,23 +220,6 @@ public function uninstall()
257220
$database->uninstallTables();
258221
}
259222

260-
/**
261-
* Intermediate method added only to keep backward compatibility with PrestaShop 1.6
262-
*
263-
* @param string $id
264-
* @param array $parameters
265-
* @param string|null $domain
266-
* @param string|null $locale
267-
*/
268-
public function trans($id, array $parameters = [], $domain = null, $locale = null)
269-
{
270-
if (method_exists('Module', 'trans')) {
271-
return parent::trans($id, $parameters, $domain, $locale);
272-
} else {
273-
return $this->l($id);
274-
}
275-
}
276-
277223
/**
278224
* Returns instance of GoogleAnalyticsTools
279225
*/

views/templates/admin/configuration.tpl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@
2525
<div id="google_analytics_content">
2626
<div class="row">
2727
<div class="col-lg-6">
28-
<p>{l s='Your customers go everywhere; shouldn\'t your analytics.' d='Modules.GAnalytics.Admin'}</p>
29-
<p>{l s='Google Analytics shows you the full customer picture across ads and videos, websites and social tools, tables and smartphones. That makes it easier to serve your current customers and win new ones.' d='Modules.GAnalytics.Admin'}</p>
30-
<p><b>{l s='With ecommerce functionality in Google Analytics you can gain clear insight into important metrics about shopper behavior and conversion, including:' d='Modules.GAnalytics.Admin'}</b></p>
28+
<p>{l s='Your customers go everywhere; shouldn\'t your analytics.' d='Modules.Googleanalytics.Admin'}</p>
29+
<p>{l s='Google Analytics shows you the full customer picture across ads and videos, websites and social tools, tables and smartphones. That makes it easier to serve your current customers and win new ones.' d='Modules.Googleanalytics.Admin'}</p>
30+
<p><b>{l s='With ecommerce functionality in Google Analytics you can gain clear insight into important metrics about shopper behavior and conversion, including:' d='Modules.Googleanalytics.Admin'}</b></p>
3131
<div class="row google-analytics-advantages-list">
32-
<div class="col-sm-6"><img src="{$module_dir}views/img/product_detail_icon.png" alt="" />{l s='Product detail views' d='Modules.GAnalytics.Admin'}</div>
33-
<div class="col-sm-6"><img src="{$module_dir}views/img/merchandising_tools_icon.png" alt="" />{l s='Internal merchandising Success' d='Modules.GAnalytics.Admin'}</div>
34-
<div class="col-sm-6"><img src="{$module_dir}views/img/add_to_cart_icon.png" alt="" />{l s='"Add to cart" actions' d='Modules.GAnalytics.Admin'}</div>
35-
<div class="col-sm-6"><img src="{$module_dir}views/img/checkout_icon.png" alt="" />{l s='The checkout process' d='Modules.GAnalytics.Admin'}</div>
36-
<div class="col-sm-6"><img src="{$module_dir}views/img/campaign_clicks_icon.png" alt="" />{l s='Internal campaign clicks' d='Modules.GAnalytics.Admin'}</div>
37-
<div class="col-sm-6"><img src="{$module_dir}views/img/purchase_icon.png" alt="" />{l s='And purchase' d='Modules.GAnalytics.Admin'}</div>
32+
<div class="col-sm-6"><img src="{$module_dir}views/img/product_detail_icon.png" alt="" />{l s='Product detail views' d='Modules.Googleanalytics.Admin'}</div>
33+
<div class="col-sm-6"><img src="{$module_dir}views/img/merchandising_tools_icon.png" alt="" />{l s='Internal merchandising Success' d='Modules.Googleanalytics.Admin'}</div>
34+
<div class="col-sm-6"><img src="{$module_dir}views/img/add_to_cart_icon.png" alt="" />{l s='"Add to cart" actions' d='Modules.Googleanalytics.Admin'}</div>
35+
<div class="col-sm-6"><img src="{$module_dir}views/img/checkout_icon.png" alt="" />{l s='The checkout process' d='Modules.Googleanalytics.Admin'}</div>
36+
<div class="col-sm-6"><img src="{$module_dir}views/img/campaign_clicks_icon.png" alt="" />{l s='Internal campaign clicks' d='Modules.Googleanalytics.Admin'}</div>
37+
<div class="col-sm-6"><img src="{$module_dir}views/img/purchase_icon.png" alt="" />{l s='And purchase' d='Modules.Googleanalytics.Admin'}</div>
3838
</div>
3939
<div class="google-analytics-create">
40-
<a href="https://support.google.com/analytics/answer/1008015" rel="external" class="btn btn-primary">{l s='Create your account to get started' d='Modules.GAnalytics.Admin'}</a>
40+
<a href="https://support.google.com/analytics/answer/1008015" rel="external" class="btn btn-primary">{l s='Create your account to get started' d='Modules.Googleanalytics.Admin'}</a>
4141
</div>
4242
</div>
4343
<div class="col-lg-6 text-center">
4444
<img src="{$module_dir}views/img/stats.png" class="img-responsive google-analytics-stats" alt="" /><br />
45-
<span class="small"><em>{l s='Merchants are able to understand how far along users get in the buying process and where they are dropping off.' d='Modules.GAnalytics.Admin'}</em></span>
45+
<span class="small"><em>{l s='Merchants are able to understand how far along users get in the buying process and where they are dropping off.' d='Modules.Googleanalytics.Admin'}</em></span>
4646
</div>
4747
</div>
4848
</div>

0 commit comments

Comments
 (0)