NikolayBezay

Tollmansdot totall cart price variable for Adoric.

Feb 4th, 2022 (edited)
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.06 KB | None | 0 0
  1. <script>
  2. (function() {
  3.     try {
  4.         var URL = window.location.origin + '/cart/';
  5.         var parser = new DOMParser();
  6.         var doc =  '';
  7.         var data = null;
  8.         var xhr = new XMLHttpRequest();
  9.         xhr.withCredentials = true;
  10.         xhr.addEventListener('readystatechange', function () {
  11.             if (this.readyState === 4) {
  12.                 doc = parser.parseFromString(this.responseText, 'text/html');      
  13.                 var totalCartAmount = doc.querySelector('.order-total .woocommerce-Price-amount.amount');
  14.                 if (totalCartAmount) {
  15.                     totalCartAmount = totalCartAmount.textContent;
  16.                     totalCartAmount = parseFloat(totalCartAmount.replaceAll('₪', ''));
  17.                     window.totalCartPrice = totalCartAmount;
  18.                 }
  19.                
  20.             }
  21.         });
  22.         xhr.open('GET', URL);
  23.         xhr.setRequestHeader('cache-control', 'no-cache');
  24.         xhr.send(data);        
  25.     } catch(error) {
  26.         console.log(error);
  27.     }
  28. })();
  29. </script>
  30.  
Add Comment
Please, Sign In to add comment