Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- var MINIMUM_TOTAL_CART_PRICE = 450;
- var MAXIMUM_TOTAL_CART_PRICE = 600;
- function getTotalCartPrice() {
- var userCart = window.sessionStorage.getItem('Cart');
- var cartTotalPrice = 0;
- if (userCart) {
- userCart = JSON.parse(userCart);
- userCart.forEach(function (item) {
- cartTotalPrice += parseFloat(item.price) * parseInt(item.quantity);
- });
- }
- window.localStorage.setItem('adoric_user_total_price', cartTotalPrice.toFixed(2));
- return cartTotalPrice.toFixed(2);
- }
- function checkTotalPriceConditions() {
- var currentUserTotalPrice = getTotalCartPrice();
- if (currentUserTotalPrice < MAXIMUM_TOTAL_CART_PRICE && currentUserTotalPrice > MINIMUM_TOTAL_CART_PRICE && adoric) {
- adoric.trigger('show_free_shipping_campaign');
- }
- }
- checkTotalPriceConditions();
- document.querySelector('body').addEventListener('click', function(event) {
- var addToCartProductOption1 = event.target.getAttribute('rel');
- var addToCartProductOption2 = event.target.getAttribute('name');
- if (addToCartProductOption1 && (addToCartProductOption1.indexOf('addproduct') != -1 || addToCartProductOption1.indexOf('addprodtobasket') != -1) ) {
- setTimeout(checkTotalPriceConditions, 1000);
- }
- if (addToCartProductOption2 && addToCartProductOption2.indexOf('addtobasket') != -1) {
- setTimeout(checkTotalPriceConditions, 1000);
- }
- });
- document.querySelector('body').addEventListener('touchend', function(event) {
- var addToCartProductOption1 = event.target.getAttribute('rel');
- var addToCartProductOption2 = event.target.getAttribute('name');
- if (addToCartProductOption1 && (addToCartProductOption1.indexOf('addproduct') != -1 || addToCartProductOption1.indexOf('addprodtobasket') != -1) ) {
- setTimeout(checkTotalPriceConditions, 1000);
- }
- if (addToCartProductOption2 && addToCartProductOption2.indexOf('addtobasket') != -1) {
- setTimeout(checkTotalPriceConditions, 1000);
- }
- });
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment