Advertisement
NikolayBezay

Impress GTM to save totalCartPrice.

Nov 18th, 2021
1,275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.70 KB | None | 0 0
  1. <script>
  2. (function() {
  3.     var waitPageTriggerElement = setInterval(function() {
  4.         var totalCartValue = document.querySelector('#header_cart .sum_all_items_price .pos_1');
  5.         if (totalCartValue) {
  6.             clearInterval(waitPageTriggerElement);
  7.             totalCartValue = totalCartValue.textContent.replace('₪', '');
  8.             window.localStorage.setItem('adoricTotalCartSum', totalCartValue);
  9.         } else {
  10.             window.localStorage.setItem('adoricTotalCartSum', 0);
  11.         }
  12.         console.log(window.localStorage.getItem('adoricTotalCartSum'));
  13.     }, 500);
  14.     setTimeout(function() {
  15.         clearInterval(waitPageTriggerElement);
  16.     }, 10000);
  17. })();
  18. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement