Skip to content

Commit 84660bc

Browse files
authored
Merge pull request #27 from AdPageGroup/fix/script-error
fix error with <<<
2 parents a6158b3 + 8b25301 commit 84660bc

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tagginggroup/gtm",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"license": "OSL-3.0",
55
"type": "magento2-module",
66
"description": "AdPage tagging integration for Magento 2",

etc/di.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
3-
<preference for="Tagging\GTM\Api\OrderCommentControllerInterface" type="Tagging\GTM\Controller\OrderCommentController"/>
43
<preference for="Tagging\GTM\Api\CheckoutSessionDataProviderInterface" type="Tagging\GTM\SessionDataProvider\CheckoutSessionDataProvider"/>
54
<preference for="Tagging\GTM\Api\CustomerSessionDataProviderInterface" type="Tagging\GTM\SessionDataProvider\CustomerSessionDataProvider"/>
6-
<preference for="Tagging\GTM\Api\OrderNotesInterface" type="Tagging\GTM\Model\OrderNotes"/>
75

86
<type name="Tagging\GTM\Logger\Debugger">
97
<arguments>

view/frontend/templates/iframe.phtml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ if ($config->isEnabled() && $config->getGoogleTagmanagerUrl() && strlen($config-
2929

3030
<?php
3131
// Main functionality script
32-
$mainScript = <<<'SCRIPT'
32+
$mainScript = '
3333
/**
3434
* Generate simple hash based only on items and quantities
3535
* @param {Object} eventData - GA4 event data
3636
* @returns {string} Base64 encoded hash
3737
*/
3838
window.tagging_gtm_simple_hash = function(eventData) {
3939
if (!eventData.ecommerce || !eventData.ecommerce.items) {
40-
return '';
40+
return "";
4141
}
4242
4343
const parts = [];
4444
4545
// Add items and quantities
4646
eventData.ecommerce.items.forEach(item => {
47-
const itemId = item.item_id || '';
47+
const itemId = item.item_id || "";
4848
const quantity = item.quantity || 0;
4949
parts.push(`i_id=${itemId}&qt=${quantity}`);
5050
});
5151
5252
// Join all parts and encode to base64
53-
const value = parts.join('&');
53+
const value = parts.join("&");
5454
return btoa(value);
5555
}
5656
@@ -61,31 +61,31 @@ window.tagging_gtm_simple_hash = function(eventData) {
6161
*/
6262
window.tagging_gtm_advanced_hash = function(eventData) {
6363
if (!eventData.ecommerce || !eventData.ecommerce.items) {
64-
return '';
64+
return "";
6565
}
6666
6767
const parts = [];
6868
6969
// Add items and quantities
7070
eventData.ecommerce.items.forEach(item => {
71-
const itemId = item.item_id || '';
71+
const itemId = item.item_id || "";
7272
const quantity = item.quantity || 0;
7373
parts.push(`i_id=${itemId}&qt=${quantity}`);
7474
});
7575
7676
// Add user agent (normalized: lowercase, spaces removed)
77-
const userAgent = navigator.userAgent || '';
78-
const normalizedUserAgent = userAgent.toLowerCase().replace(/\s+/g, '');
77+
const userAgent = navigator.userAgent || "";
78+
const normalizedUserAgent = userAgent.toLowerCase().replace(/\s+/g, "");
7979
parts.push(`--ua=${normalizedUserAgent}`);
8080
8181
// Join all parts and encode to base64
82-
const value = parts.join('&');
82+
const value = parts.join("&");
8383
return btoa(value);
8484
}
8585
8686
window.tagging_gtm_save_hash = function(hash, marketingObject) {
8787
if (!hash || !marketingObject) {
88-
console.error('Hash or marketingObject is missing');
88+
console.error("Hash or marketingObject is missing");
8989
return;
9090
}
9191
@@ -104,8 +104,7 @@ window.tagging_gtm_save_hash = function(hash, marketingObject) {
104104
.catch((err) => {
105105
console.error(`Error sending data to API`, err);
106106
});
107-
}
108-
SCRIPT;
107+
}';
109108

110109
if ($isHyva): ?>
111110
<script><?= $mainScript ?></script><?php $hyvaCsp->registerInlineScript() ?>

0 commit comments

Comments
 (0)