Skip to content

Commit

Permalink
Prevent JS error Cannot read properties of undefined under Hyva #181
Browse files Browse the repository at this point in the history
  • Loading branch information
jissereitsma committed Jul 21, 2023
1 parent 7a91338 commit 7fd59cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 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.6] - 21 July 2023
### Fixed
- Prevent JS error `Cannot read properties of undefined` under Hyva #181

## [3.5.5] - 21 July 2023
### Fixed
- Make sure that shipment code is added, if missing in address
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.5",
"version": "3.5.6",
"license": "OSL-3.0",
"type": "magento2-module",
"homepage": "https://www.yireo.com/software/magento-extensions/googletagmanager2",
Expand Down
6 changes: 4 additions & 2 deletions view/frontend/templates/hyva/script-additions.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ $commons = $block->getCommonsViewModel();
mageCacheStorage = JSON.parse(mageCacheStorage);
}

if (typeof mageCacheStorage.cart.gtm_events[eventId] !== undefined) {
if (mageCacheStorage !== null &&
typeof mageCacheStorage.cart !== undefined &&
typeof mageCacheStorage.cart.gtm_events[eventId] !== undefined) {
delete mageCacheStorage.cart.gtm_events[eventId];
}

window.localStorage.setItem('mage-cache-storage', JSON.stringify(mageCacheStorage));
}
}
Expand Down

0 comments on commit 7fd59cd

Please sign in to comment.