Advertisement
NikolayBezay

Crazyline GTM teg to show accessories sale campaign(updated).

Mar 23rd, 2023 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <script>
  2. (function () {
  3. function updateWhiteListCheckResult() {
  4. var whiteListProducts = ['291087', '287853', '292934', '291092', '292935', '292939', '291084', '291085', '292936', '287881', '287861', '290145', '290152', '287862', '287863', '287864', '290146', '289067', '287984', '287832', '287833', '287859', '290147', '288879', '287838', '288878', '289825', '287878', '289065', '289066', '287846', '287847', '287850', '287851', '291090', '287834', '287835', '287854', '288606', '288603', '289149', '289150', '287848', '287849', '287858', '287880', '287860', '287836', '287986', '289045', '287983', '287828', '289827', '287985', '287606', '287607', '288877', '288602', '285991', '287509', '287510', '284298', '285740', '281807', '281823', '281804', '274599', '274604'];
  5. var productsData = JSON.parse(window.localStorage.getItem('mage-cache-storage'));
  6. if (productsData && productsData.cart && productsData.cart.items) {
  7. productsData = productsData.cart.items;
  8. var isItemInWhiteList = false;
  9. productsData.forEach(function(item) {
  10. isItemInWhiteList = whiteListProducts.some(function(productData) {
  11. return productData === item.product_id;
  12. });
  13. if (isItemInWhiteList) {
  14. window.showAccessoriesSale = true;
  15. return null;
  16. }
  17. });
  18. }
  19. }
  20. updateWhiteListCheckResult();
  21. document.querySelector('BODY').addEventListener('click', updateWhiteListCheckResult);
  22. document.querySelector('BODY').addEventListener('touched', updateWhiteListCheckResult);
  23. })();
  24. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement