Skip to content

Commit

Permalink
Make sure undefined YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS does not c…
Browse files Browse the repository at this point in the history
…ause issues
  • Loading branch information
jissereitsma committed Jul 4, 2023
1 parent 78dce3e commit 21aa6bd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/templates/hyva/script-product-clicks.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down
6 changes: 1 addition & 5 deletions view/frontend/web/js/mixins/catalog-add-to-cart-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/product/clicks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 21aa6bd

Please sign in to comment.