Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- function checkCartTotalPrice(pageSubtotal) {
- localStorage.setItem('pageTotalPrice', pageSubtotal);
- var MINIMUM_CART_TOTAL = 50;
- var MAXIMUM_CART_TOTAL = 140;
- if (pageSubtotal > MINIMUM_CART_TOTAL && pageSubtotal < MAXIMUM_CART_TOTAL) {
- window.pageTotalPrice = pageSubtotal;
- adoric && adoric.trigger('showByMinimalPrice');
- }
- MINIMUM_CART_TOTAL = 299;
- if (pageSubtotal < MINIMUM_CART_TOTAL) {
- adoric && adoric.trigger('showForLes299Price');
- }
- }
- function addToCartCustomHandler(){
- setTimeout(function() {
- var URL = 'https://www.sebocalm.co.il/cart/';
- 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 pageSubtotal = doc.querySelector('.bag-total > .woocommerce-Price-amount.amount');
- if (pageSubtotal) {
- pageSubtotal = pageSubtotal.textContent.replace('₪','').replace(',','');
- checkCartTotalPrice(parseFloat(pageSubtotal));
- }
- }
- });
- xhr.open('GET', URL);
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(data);
- }, 1500);
- }
- addToCartCustomHandler();
- var addToCartButtonType1 = document.querySelector('.add-to-cart-btn');
- var addToCartButtonType2 = document.querySelectorAll('.add_to_cart_button');
- if (addToCartButtonType1) {
- addToCartButtonType1.addEventListener('click', addToCartCustomHandler);
- }
- for(var i = 0; i < addToCartButtonType2.length; i++ ) {
- addToCartButtonType2[i].addEventListener('click', addToCartCustomHandler);
- }
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement