NikolayBezay

Keds show free shipping campaign for all pages.

Nov 23rd, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.80 KB | None | 0 0
  1. <script>
  2.     (function() {
  3.         var FREE_SHIPPING_MINIMUM_PRICE = 100;
  4.         var FREE_SHIPPING_MAXIMUM_PRICE = 198;
  5.         var FREQUENCY_LIMITATION_PER_SESSION = 2;
  6.  
  7.         function checkFreeShipping() {
  8.             var pageTotalPrice = document.querySelector('.minicart-wrapper .subtotal .price');
  9.             if (pageTotalPrice) {
  10.                 pageTotalPrice = pageTotalPrice.textContent;
  11.                 pageTotalPrice = pageTotalPrice.replace('₪', '');
  12.                 pageTotalPrice = parseInt(pageTotalPrice);
  13.             }
  14.             var showedByCurrentSession = parseInt(sessionStorage.getItem('isAdoricFreeShipingShowed'));            
  15.             if (!showedByCurrentSession) {
  16.                 showedByCurrentSession = 0;
  17.             }
  18.             if (adoric &&
  19.                pageTotalPrice > FREE_SHIPPING_MINIMUM_PRICE &&
  20.                pageTotalPrice < FREE_SHIPPING_MAXIMUM_PRICE &&
  21.                showedByCurrentSession < FREQUENCY_LIMITATION_PER_SESSION) {
  22.                    adoric.trigger('show_AdoricFreeShiping');
  23.                     showedByCurrentSession++;
  24.                     sessionStorage.setItem('isAdoricFreeShipingShowed', showedByCurrentSession);
  25.             }
  26.    
  27.    
  28.         }
  29.    
  30.         var waitPageTriggerElement = setInterval(function() {
  31.             var pageTriggerElements = document.querySelector('#product_addtocart_form .btn-cart');
  32.             if (pageTriggerElements) {
  33.                 clearInterval(waitPageTriggerElement);
  34.                 pageTriggerElements.addEventListener('click', function() {
  35.                     setTimeout(checkFreeShipping, 2500);
  36.                 });
  37.             }
  38.         }, 1000);
  39.         setTimeout(function() {
  40.             clearInterval(waitPageTriggerElement);
  41.         }, 7000);
  42.     })();        
  43. </script>
Advertisement
Add Comment
Please, Sign In to add comment