NikolayBezay

IQOS check product color GTM teg

Nov 10th, 2020 (edited)
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.04 KB | None | 0 0
  1. <script>
  2.     (function() {
  3.         function checkProductPrice() {
  4.             var isPurpleEsist = false;
  5.             var productTitles = document.querySelectorAll('#cart_items li a[class*="product-title"], #cart_items li .colors-wrapper');
  6.             for(var i = 0; i < productTitles.length; i++) {
  7.                var productTitleOrColor = productTitles[i].textContent;
  8.                if (productTitleOrColor.toLowerCase().trim().indexOf('purple') != -1) {
  9.                    isPurpleEsist = true;
  10.                }
  11.            }
  12.            window.sessionStorage.setItem('isCartContainsPurpleItem', isPurpleEsist);
  13.        }
  14.        
  15.        var checkItems = setInterval(function() {
  16.            var productItems = document.querySelectorAll('#cart_items li');
  17.            if (productItems.length > 0 ) {
  18.                 checkProductPrice();
  19.                 clearInterval(checkItems);
  20.             }
  21.         }, 1000);
  22.        
  23.         setTimeout(function() {
  24.             clearInterval(checkItems);
  25.         }, 7000);
  26.     })();
  27. </script>
Advertisement
Add Comment
Please, Sign In to add comment