Untitled
unknown
plain_text
3 years ago
5.7 kB
3
Indexable
jQuery('body').on('click', '.product_minus', function() { var elem = jQuery(this).parent().find(".units_selected"); //var product_id = elem.attr('data-product-id'); var unit = parseInt(elem.html())-1; if(elem.attr('data-product-id')==3080){ if(unit<=1){ jQuery('.one-bottle-price').show(); jQuery('.two-bottles-price, .three-bottles-price').hide(); } else if(unit==2){ jQuery('.two-bottles-price').show(); jQuery('.one-bottle-price, .three-bottles-price').hide(); } else if(unit>2){ jQuery('.three-bottles-price').show(); jQuery('.one-bottle-price, .two-bottles-price').hide(); } } if(unit>=0){ jQuery(this).parent().find(".units_selected").html(unit); var productIdArr = jQuery(".units_selected").map(function(){ if(parseInt(jQuery(this).html())){ return jQuery(this).attr('data-product-id'); } }).get(); var product_id = productIdArr.join(','); var qty = jQuery(".units_selected").map(function(){ if(parseInt(jQuery(this).html())){ return jQuery(this).html(); } }).get().join(','); var url = 'https://brainchai.com/checkouts/checkout-page/?aero-add-to-checkout='+product_id+'&aero-qty='+qty; if(productIdArr.length){ jQuery('a.buy-now-cta-button').attr('href',url); } else { jQuery('a.buy-now-cta-button').attr('href','javascript:void(0);'); } } var totalQtyArr = jQuery(".units_selected").map(function(){ if(parseInt(jQuery(this).html())){ return parseInt(jQuery(this).html()); } }).get(); if(!totalQtyArr.reduce(function(a,b){ return a+b },0)){ $('.empty_cart_error').show(); } else { $('.empty_cart_error').hide(); } var qtyArr = jQuery(".units_selected:lt(2)").map(function(){ if(parseInt(jQuery(this).html())){ return parseInt(jQuery(this).html()); } }).get(); var firstTwoTotal = qtyArr.reduce(function(a,b){ return a+b },0); if(firstTwoTotal==0){ jQuery('.saving_percent').hide().html('Спестяваш 0%'); jQuery('.cost_per_bag').show().html('Само 24.99лв./пакет'); } if(firstTwoTotal==1){ jQuery('.saving_percent').hide(); jQuery('.cost_per_bag').show().html('Само 24.99лв./пакет'); } if(firstTwoTotal==2){ jQuery('.saving_percent').show().html('Спестяваш 16%'); jQuery('.cost_per_bag').html('<b>само 20.99лв/пакет</b> <SPAN STYLE="text-decoration:line-through">24.99лв</span>'); } else if(firstTwoTotal>2 && firstTwoTotal<=4){ jQuery('.saving_percent').show().html('Спестяваш 21%'); jQuery('.cost_per_bag').html('<b>само 19.74лв/пакет</b> <SPAN STYLE="text-decoration:line-through">24.99лв</span>'); } else if(firstTwoTotal>4){ jQuery('.saving_percent').show().html('Спестяваш 26%'); jQuery('.cost_per_bag').html('<b>само 18.49лв/пакет</b> <SPAN STYLE="text-decoration:line-through">24.99лв</span>'); } }); jQuery(".buy-now-cta-button").click(function(evt) { evt.preventDefault(); var href = jQuery(this).attr('href'); if(href){ window.location.href = href; } }); jQuery('body').on('click', '.product_plus', function() { //console.log('index', $(this).index() ); var elem = jQuery(this).parent().find(".units_selected"); //var product_id = elem.attr('data-product-id'); var unit = parseInt(elem.html())+1; if(elem.attr('data-product-id')==3080){ if(unit<=1){ jQuery('.one-bottle-price').show(); jQuery('.two-bottles-price, .three-bottles-price').hide(); } else if(unit==2){ jQuery('.two-bottles-price').show(); jQuery('.one-bottle-price, .three-bottles-price').hide(); } else if(unit>2){ jQuery('.three-bottles-price').show(); jQuery('.one-bottle-price, .two-bottles-price').hide(); } } jQuery(this).parent().find(".units_selected").html(unit); var product_id = jQuery(".units_selected").map(function(){ if(parseInt(jQuery(this).html())){ return jQuery(this).attr('data-product-id'); } }).get().join(','); var qty = jQuery(".units_selected").map(function(){ if(parseInt(jQuery(this).html())){ return jQuery(this).html(); } }).get().join(','); var url = 'https://brainchai.com/checkouts/checkout-page/?aero-add-to-checkout='+product_id+'&aero-qty='+qty; jQuery('a.buy-now-cta-button').attr('href',url); var totalQtyArr = jQuery(".units_selected").map(function(){ if(parseInt(jQuery(this).html())){ return parseInt(jQuery(this).html()); } }).get(); if(!totalQtyArr.reduce(function(a,b){ return a+b },0)){ $('.empty_cart_error').show(); } else { $('.empty_cart_error').hide(); } var qtyArr = jQuery(".units_selected:lt(2)").map(function(){ if(parseInt(jQuery(this).html())){ return parseInt(jQuery(this).html()); } }).get(); var firstTwoTotal = qtyArr.reduce(function(a,b){ return a+b },0); //console.log('firstTwoTotal',firstTwoTotal) if(firstTwoTotal==0){ jQuery('.saving_percent').hide().html('Спестяваш 0%'); jQuery('.cost_per_bag').show().html('Само 24.99лв./пакет'); } if(firstTwoTotal==1){ jQuery('.saving_percent').hide(); jQuery('.cost_per_bag').show().html('Само 24.99лв./пакет'); } if(firstTwoTotal==2){ jQuery('.saving_percent').show().html('Спестяваш 16%'); jQuery('.cost_per_bag').html('<b>само 20.99лв/пакет</b> <SPAN STYLE="text-decoration:line-through">24.99лв</span>'); } else if(firstTwoTotal>2 && firstTwoTotal<=4){ jQuery('.saving_percent').show().html('Спестяваш 21%'); jQuery('.cost_per_bag').html('<b>само 19.74лв/пакет</b> <SPAN STYLE="text-decoration:line-through">24.99лв</span>'); } else if(firstTwoTotal>4){ jQuery('.saving_percent').show().html('Спестяваш 26%'); jQuery('.cost_per_bag').html('<b>само 18.49лв/пакет</b> <SPAN STYLE="text-decoration:line-through">24.99лв</span>'); } });
Editor is loading...