Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- var minPrice = 100;
- var maxPrice = 149;
- var FREE_SHIPPING = 150;
- function checkTotalCart() {
- var parser = new DOMParser();
- var doc = '';
- var data = null;
- var xhr = new XMLHttpRequest();
- xhr.withCredentials = true;
- xhr.addEventListener('readystatechange', function () {
- if (this.readyState === 4) {
- doc = parser.parseFromString(this.responseText, 'text/html');
- var cartData = JSON.parse(doc.querySelector('body').innerText, 2);
- var totalPrice = cartData.total_price;
- totalPrice = parseInt(totalPrice / 100);
- window.localStorage.setItem('adoricTotalCartPrice', totalPrice);
- if ((totalPrice >= minPrice) && (totalPrice <= maxPrice)) {
- window.localStorage.setItem('adoricFreeShipping', FREE_SHIPPING - totalPrice);
- window.adoric && adoric.trigger('FreeDelivery');
- }
- }
- });
- xhr.open('GET', window.location.origin + '/cart.js');
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(data);
- }
- setTimeout(checkTotalCart, 2000);
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment