diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc3d138..f2e8260a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.5.1] - 4 July 2023 +### Fixed +- Make sure undefined `YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS` does not cause issues + ## [3.5.0] - 4 July 2023 ### Fixed - Automagically add an index to every product being mapped #169 diff --git a/composer.json b/composer.json index 4dc426ce..cb5a9297 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "yireo/magento2-googletagmanager2", - "version": "3.5.0", + "version": "3.5.1", "license": "OSL-3.0", "type": "magento2-module", "homepage": "https://www.yireo.com/software/magento-extensions/googletagmanager2", diff --git a/view/frontend/templates/hyva/script-product-clicks.phtml b/view/frontend/templates/hyva/script-product-clicks.phtml index 9f439127..4fa86a74 100644 --- a/view/frontend/templates/hyva/script-product-clicks.phtml +++ b/view/frontend/templates/hyva/script-product-clicks.phtml @@ -46,7 +46,7 @@ $productPath = $block->getProductPath(); yireoGoogleTagManager2Pusher(eventData, 'push (page event "select_item") [script-product-clicks.phtml]'); - if (YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS && confirm("Press to continue with redirect") === false) { + if (window['YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS'] && confirm("Press to continue with redirect") === false) { event.preventDefault(); } }); diff --git a/view/frontend/web/js/mixins/catalog-add-to-cart-mixin.js b/view/frontend/web/js/mixins/catalog-add-to-cart-mixin.js index c661a90b..b1abbd65 100644 --- a/view/frontend/web/js/mixins/catalog-add-to-cart-mixin.js +++ b/view/frontend/web/js/mixins/catalog-add-to-cart-mixin.js @@ -16,11 +16,7 @@ define([ const formData = Object.fromEntries(new FormData(form[0]).entries()); const productId = formData.product; - let debugClicks = false; - if (typeof YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS !== 'undefined') { - debugClicks = YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS; - } - + const debugClicks = window['YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS'] || false; const productData = window['YIREO_GOOGLETAGMANAGER2_PRODUCT_DATA_ID_' + productId] || {}; productData.quantity = formData.qty || 1; diff --git a/view/frontend/web/js/product/clicks.js b/view/frontend/web/js/product/clicks.js index 1849ee54..1ec14529 100644 --- a/view/frontend/web/js/product/clicks.js +++ b/view/frontend/web/js/product/clicks.js @@ -5,7 +5,7 @@ define([ return function(config, element) { const productPath = config.productPath || '.product-items a.product'; $(productPath).click(function(event) { - const debugClicks = YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS || false; + const debugClicks = window['YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS'] || false; const $parent = $(this).closest('[id^=product_item_info_]'); const regex = /_(\d+)$/; const matches = $parent.attr('id').match(regex);