var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); var cart_reload_promo_text = ''; jQuery( document ).ready(function( $ ) { jQuery( "#wpshop_cart" ).on( "click","input#promocode_button_block",function() { promocode=jQuery("#promocode_block").val(); jQuery.post( object_name.url+"/wp-admin/admin-ajax.php", { action: "cart_promocode",promocode:promocode}) .done(function( data ) { cart_reload_promo_text = data; window.__cart.update(); }); }); }); var CURR = ' '; var SPL = '}{'; var cart_col_name = object_name.name; var cart_col_price = object_name.price; var cart_col_count = object_name.count; var cart_col_sum = object_name.sum; var cart_col_type = ''; function wshop(url,cart,win) { var self = this; var _url = url; // url with hash of prodovator var gSellers = []; // global array for this class of sellers var _cart = cart; var _win = win; this.findElement = function(arr,id) { var result = -1; jQuery.each(arr, function(i,item) { if (item.id == id) { result = i; return; } }); return result; } } function Cart(eid_mini, eid_cart) { this.mini = document.getElementById(eid_mini); this.cart = document.getElementById(eid_cart); this.discount = 0; var OnUpdate = undefined; var wps = undefined; var CARTTHIS = this; this.init = function() { this.count = 0; this.a_id = new Array(); this.a_key = new Array(); this.a_name = new Array(); this.a_href = new Array(); this.a_num = new Array(); this.a_cost = new Array(); this.a_sklad = new Array(); this.a_promo = new Array(); this.promo_code = ''; this.s_id = ''; this.s_key = ''; this.s_name = ''; this.s_href = ''; this.s_num = ''; this.s_cost = ''; this.s_sklad = ''; } this.save = function() { jQuery.ajax({ type: "POST", url: object_name.url+"/wp-admin/admin-ajax.php", data: {action:'cart_save',wpshop_id:this.s_id,wpshop_key:window.__cart.s_key,wpshop_name:window.__cart.s_name,wpshop_href:window.__cart.s_href,wpshop_cost:window.__cart.s_cost,wpshop_num:window.__cart.s_num,wpshop_sklad:window.__cart.s_sklad}, success: function(t){ if (jQuery.trim(t) == "add") { if (object_name.show_panel==1){ jQuery('
').prependTo('body'); if (object_name.yandex!= undefined){ jQuery('
'+object_name.success+'
').prependTo('body'); }else{ jQuery('
'+object_name.success+'
').prependTo('body'); } jQuery('#continueButton').click(function() { jQuery('#wpshop_shadow_window').remove(); jQuery('#wpshop_background_alert_put_to_cart').remove(); return false; }); } if (object_name.show_panel==2){ window.location.href =object_name.cartpage; } } } }); } this.closeShadowWindow = function() { } this.getTotalSum = function() { var total = 0; var i = 0; for (i = 0; i < this.count; i++) { t = parseFloat(this.a_cost[i]) * this.a_num[i]; t = t.toFixed(2); t = t * 1; total += t; } var tmp = String(this.discount).split(";"); var max_discount = 0; for (property in tmp) { var t = tmp[property].split(':'); if (total > t[0]) { if ((max_discount*1) < (t[1]*1)) { max_discount = t[1]; } } } total = (total / 100 * (100-max_discount)).toFixed(2); return total; } this.afterChange = function() { jQuery("[name='select_delivery']").change(function() { var deliveryCost = (jQuery(this).find('option:selected').attr('cost') * 1).toFixed(2); jQuery('#delivery_cost_value').html(deliveryCost); var all_price = jQuery('.all_price .rb_total strong').text()*1; var discount_row = jQuery('.discount_row .rb_total strong').text()*1; if(discount_row){var total_p = discount_row;}else{var total_p = all_price;} jQuery('#delivery_cost_total').html((total_p*1 + deliveryCost*1).toFixed(2)); jQuery('#delivery_cost').css('display','table-row'); jQuery('#delivery_cost').width(jQuery(".recycle_bin").width()); jQuery(".cform input[name='delivery']").val(jQuery(this).find('option:selected').val()); }).change(); } this.afterChange1 = function() { if(jQuery('ul.custom_del').length != 0){ var deliveryCost1 = (jQuery("ul.custom_del li.select").find('> a.info').attr('cost') * 1).toFixed(2); var deliveryName1 = jQuery("ul.custom_del li.select").find('> a.info').text(); var deliveryLink1 = jQuery("ul.custom_del li.select").find('> a.info').attr('link'); jQuery('#delivery_cost_value').html(deliveryCost1); jQuery('#delivery_name').html(deliveryName1); jQuery('#delivery_link').attr('href',deliveryLink1); jQuery('#delivery_cost #delivery_link').html('?'); var all_price = jQuery('.all_price .rb_total strong').text()*1; var discount_row = jQuery('.discount_row .rb_total strong').text()*1; if(discount_row){var total_p = discount_row;}else{var total_p = all_price;} jQuery('#delivery_cost_total').html((total_p*1 + deliveryCost1*1).toFixed(2)); jQuery('#delivery_cost').css('display','table-row'); jQuery('#delivery_cost').width(jQuery(".recycle_bin").width()); jQuery(".cform input[name='delivery']").val(deliveryName1); jQuery("ul.custom_del li > a.img, ul.custom_del li > a.info").click(function() { jQuery("ul.custom_del").find('li.select').removeClass('select'); jQuery(this).parent("li").addClass('select'); var deliveryCost2 = (jQuery("ul.custom_del li.select").find('> a.info').attr('cost') * 1).toFixed(2); var deliveryName2 = jQuery("ul.custom_del li.select").find('> a.info').text(); var deliveryLink2 = jQuery("ul.custom_del li.select").find('> a.info').attr('link'); jQuery('#delivery_cost_value').html(deliveryCost2); jQuery('#delivery_name').html(deliveryName2); jQuery('#delivery_link').attr('href',deliveryLink2); jQuery('#delivery_cost #delivery_link').html('?'); jQuery('#delivery_cost_total').html((CARTTHIS.getTotalSum()*1 + deliveryCost2*1).toFixed(2)); jQuery('#delivery_cost').css('display','table-row'); jQuery('#delivery_cost').width(jQuery(".recycle_bin").width()); jQuery(".cform input[name='delivery']").val(deliveryName2); }); jQuery("#delivery_cost #delivery_link").click(function() { jQuery('
').prependTo('body'); jQuery('
x
').prependTo('body'); var deliveryLink = jQuery("ul.custom_del li.select").find('> a.info').attr('link'); jQuery('.data').load( deliveryLink+" #main-content .load" ); return false; }); jQuery("ul.custom_del li .delivery_link_more").unbind().click(function() { jQuery('
').prependTo('body'); jQuery('
x
').prependTo('body'); var deliveryLink1 = jQuery(this).attr('href'); jQuery('.data').load( deliveryLink1+" #main-content .load" ); return false; }); jQuery('body').on("click", "a#close", function() { jQuery('#wpshop_shadow_window').remove(); jQuery('#wpshop_modal').remove(); return false; }); } } this.update = function() { var $_GET = {}; document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { function decode(s) { return decodeURIComponent(s.split("+").join(' ')); } $_GET[decode(arguments[1])] = decode(arguments[2]); }); jQuery.ajax({ type: "POST", url:object_name.url+"/wp-admin/admin-ajax.php", data: {action:'cart_load'}, success: function(t){ eval(t); if (window.__cart.count) { window.__cart.content_mini = '
'; window.__cart.content_cart = ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''; var i, t,c, total,promo; for (i = 0, total = 0; i < window.__cart.count; i++) { t = parseFloat(window.__cart.a_cost[i]) * window.__cart.a_num[i]; t = t.toFixed(2); t = t * 1; c = parseFloat(window.__cart.a_cost[i]); c = c.toFixed(2); c = c * 1; if(window.__cart.a_promo[i]!=0) { promo = parseFloat(window.__cart.a_promo[i]); } total += t; if(window.__cart.a_sklad[i]>0){stock='
'+object_name.stock+window.__cart.a_sklad[i]+''+object_name.pcs;}else{stock='';} window.__cart.content_cart += '' + '' + '' + '' + '' + '' + '' + '' + ''; } total = total.toFixed(2)*1; window.__cart.content_cart += ''+ ''+ ''+ ''+ '' + ''; if (window.__cart.discount != 0 && window.__cart.discount != undefined) { var tmp = String(window.__cart.discount).split(";"); var max_discount = 0; for (property in tmp) { var t = String(tmp[property]).split(':'); if (total*1 > t[0]) { if ((max_discount*1) < (t[1]*1)) { max_discount = t[1]; } } } if (max_discount > 0) { var price = (total / 100 * (100-max_discount)).toFixed(2); setcookie('wpshop_discount', max_discount, 0, '/'); setcookie('wpshop_new_price', price, 0, '/'); window.__cart.content_cart += ''+ ''+ ''+ '' + ''; } else { setcookie('wpshop_discount', 0, 0, '/'); } } window.__cart.content_cart += ""; if (object_name.promocode== 1){ window.__cart.content_cart += ""; if (cart_reload_promo_text !=''&&cart_reload_promo_text !='NO'){ window.__cart.content_cart += ""; } if (cart_reload_promo_text =='NO'){ window.__cart.content_cart += ""; } if(promo) { window.__cart.content_cart += ""; } } window.__cart.content_cart +=''+'
' + window.cart_col_name + '' + window.cart_col_type + '' + window.cart_col_price + ' ('+ CURR +')'+ window.cart_col_count + '' + window.cart_col_sum + ' ('+ CURR +') 
'+ window.__cart.a_name[i] +''+ window.__cart.a_key[i] +' '+c+' +'+ stock +''+ t +'×
'+object_name.total+''+total+'×
'+object_name.discont+' '+ max_discount + '%. '+object_name.full_total+''+ price+'
 
"+cart_reload_promo_text+"
"+object_name.wrong_promocode+"
"+object_name.your_promocode+window.__cart.promo_code+"
'; window.__cart.content_mini += '
'+object_name.items+' '+window.__cart.count+'
'+ '
'+object_name.total_sum+' '+total+' '+CURR+'
'+ '
'+ '
'; if (window.__cart.count && $_GET["step"]!='2' && $_GET["step"]!='3' && $_GET['payment'] == undefined && typeof $_GET['page_id'] === "undefined"){ window.__cart.content_cart += '

'+ ''; if (object_name.yandex!= undefined){ window.__cart.content_cart +=''}else{ window.__cart.content_cart +='' } window.__cart.content_cart += object_name.submit+''+ ''+object_name.cont_shop+''+ '
'; } if (window.__cart.count && $_GET["step"]!='2' && $_GET["step"]!='3' && $_GET['payment'] == undefined && typeof $_GET['page_id'] !== "undefined"){ window.__cart.content_cart += '

'+ ''+object_name.submit+''+ ''+object_name.cont_shop+''+ '
'; } } else { window.__cart.content_mini = '
'+object_name.is_empty+'
'; window.__cart.content_cart = '
'+object_name.is_empty+'
'; } if (window.__cart.mini) { window.__cart.mini.innerHTML = window.__cart.content_mini; } if (window.__cart.cart) { window.__cart.cart.innerHTML = window.__cart.content_cart; } window.__cart.afterChange(); window.__cart.afterChange1(); } }); } this.reset = function() { this.is_empty = true; this.content_mini = ''; this.content_cart = ''; jQuery.ajax({ type: "POST", url: object_name.url+"/wp-admin/admin-ajax.php?action=cart_remove", data: {action:'cart_remove',wpshop_id:-1}, success: function(t){ for (i=0; i tfoot > tr.all_price > td.rb_total strong").html(); jQuery(".recycle_bin > tfoot > tr.all_price > td.rb_total strong").html(local_price_all-local_price); var tmp1 = String(window.__cart.discount).split(";"); var max_discount_n = 0; for (property in tmp1) { var ti = String(tmp1[property]).split(':'); if ((local_price_all-local_price)*1 > ti[0]) { if ((max_discount_n*1) < (ti[1]*1)) { max_discount_n = ti[1]; } } } if (max_discount_n*1 > 0) { if(jQuery(".recycle_bin > tfoot > tr.discount_row").length>0){jQuery(".recycle_bin > tfoot > tr.discount_row").show();}else{ jQuery(".recycle_bin > tfoot > tr.all_price").after(''+ ''+object_name.discont+' ' + max_discount_n + '%. '+object_name.full_total+''+ ''+ '' + ''); } var price_n = ((local_price_all-local_price) / 100 * (100-max_discount_n)).toFixed(2); jQuery(".recycle_bin > tfoot > tr.discount_row > td.rb_total strong").html(price_n); jQuery(".recycle_bin > tfoot > tr.discount_row > td:first-child").html(''+object_name.discont+' ' + max_discount_n + '%. '+object_name.full_total+''); }else{jQuery(".recycle_bin > tfoot > tr.discount_row").hide();} } this.set = function(id, key, value,index,sklad,cost) { if ((sklad >= Math.abs(parseFloat(value)) || sklad == 0)&&Math.abs(parseFloat(value))>0){ this.s_id = id; this.s_key = key; this.s_num = Math.abs(parseFloat(value)); this.save(); var res = parseFloat(value)*cost; jQuery(".input_" + index).parent().closest('tr').find(".rb_total").html(res); var all_sum = 0; jQuery("tbody tr.rb_item .rb_total").each(function(){ all_sum += parseFloat(jQuery(this).text()); return all_sum; }); jQuery(".recycle_bin > tfoot > tr.all_price > td.rb_total strong").html(all_sum); var tmp1 = String(window.__cart.discount).split(";"); var max_discount_n = 0; for (property in tmp1) { var ti = String(tmp1[property]).split(':'); if (all_sum*1 > ti[0]) { if ((max_discount_n*1) < (ti[1]*1)) { max_discount_n = ti[1]; } } } if (max_discount_n*1 > 0) { if(jQuery(".recycle_bin > tfoot > tr.discount_row").length>0){jQuery(".recycle_bin > tfoot > tr.discount_row").show();}else{ jQuery(".recycle_bin > tfoot > tr.all_price").after(''+ ''+object_name.discont+' ' + max_discount_n + '%. '+object_name.full_total+''+ ''+ '' + ''); } var price_n = (all_sum / 100 * (100-max_discount_n)).toFixed(2); jQuery(".recycle_bin > tfoot > tr.discount_row > td.rb_total strong").html(price_n); jQuery(".recycle_bin > tfoot > tr.discount_row > td:first-child").html(''+object_name.discont+' ' + max_discount_n + '%. '+object_name.full_total+''); }else{jQuery(".recycle_bin > tfoot > tr.discount_row").hide();} var deliveryCost = (jQuery("select[name='select_delivery']").find('option:selected').attr('cost') * 1).toFixed(2); var deliveryCost1 = (jQuery("ul.custom_del li.select").find('> a.info').attr('cost') * 1).toFixed(2); if(jQuery("select[name='select_delivery']").length > 0) { if (price_n>0){ var del_price = price_n*1 + deliveryCost*1; }else{ var del_price = all_sum*1 + deliveryCost*1; } jQuery("#delivery_cost_total").text(del_price); } if(jQuery("ul.custom_del").length > 0) { if (price_n>0){ var del_price = price_n*1 + deliveryCost1*1; }else{ var del_price = all_sum*1 + deliveryCost1*1; } jQuery("#delivery_cost_total").text(del_price); } //this.update(); }else if(sklad > 0){ alert(object_name.stock_error);jQuery(".input_" + index).val(1);} } /** * @since 17.04.2011 Вводится понятие индекса. Если он указан, то поиск элемента не делается. */ this.plus = function(id, key, value, index, sklad,cost) { if (sklad >= (jQuery(".input_" + index).val()*1+1) || sklad == 0){ var sum = jQuery(".input_" + index).val()*1+1; this.s_id = id; this.s_key = key; this.s_num = sum; this.s_name = ''; this.s_href = ''; this.s_cost = ''; this.save(); var res = (sum*cost).toFixed(2); jQuery(".minus_" + index).parent().closest('tr').find(".rb_total").html(res); var all_sum = 0; jQuery("tbody tr.rb_item .rb_total").each(function(){ all_sum += parseFloat(jQuery(this).text()); return all_sum; }); jQuery(".recycle_bin > tfoot > tr.all_price > td.rb_total strong").html(all_sum); var tmp1 = String(window.__cart.discount).split(";"); var max_discount_n = 0; for (property in tmp1) { var ti = String(tmp1[property]).split(':'); if (all_sum*1 > ti[0]) { if ((max_discount_n*1) < (ti[1]*1)) { max_discount_n = ti[1]; } } } if (max_discount_n*1 > 0) { if(jQuery(".recycle_bin > tfoot > tr.discount_row").length>0){jQuery(".recycle_bin > tfoot > tr.discount_row").show();}else{ jQuery(".recycle_bin > tfoot > tr.all_price").after(''+ ''+object_name.discont+' ' + max_discount_n + '%. '+object_name.full_total+''+ ''+ '' + ''); } var price_n = (all_sum / 100 * (100-max_discount_n)).toFixed(2); jQuery(".recycle_bin > tfoot > tr.discount_row > td.rb_total strong").html(price_n); jQuery(".recycle_bin > tfoot > tr.discount_row > td:first-child").html(''+object_name.discont+' ' + max_discount_n + '%. '+object_name.full_total+''); }else{jQuery(".recycle_bin > tfoot > tr.discount_row").hide();} var deliveryCost = (jQuery("select[name='select_delivery']").find('option:selected').attr('cost') * 1).toFixed(2); var deliveryCost1 = (jQuery("ul.custom_del li.select").find('> a.info').attr('cost') * 1).toFixed(2); if(jQuery("select[name='select_delivery']").length > 0) { if (price_n>0){ var del_price = price_n*1 + deliveryCost*1; }else{ var del_price = all_sum*1 + deliveryCost*1; } jQuery("#delivery_cost_total").text(del_price); } if(jQuery("ul.custom_del").length > 0) { if (price_n>0){ var del_price = price_n*1 + deliveryCost1*1; }else{ var del_price = all_sum*1 + deliveryCost1*1; } jQuery("#delivery_cost_total").text(del_price); } jQuery(".input_" + index).val(sum); }else if(sklad > 0){ alert(object_name.stock_error);} } this.minus = function(id, key, value, index,cost) { var sum = jQuery(".input_" + index).val()-1; if (sum < 1) sum = 1; this.s_id = id; this.s_key = key; this.s_num =sum; this.s_name = ''; this.s_href = ''; this.s_cost = ''; this.save(); var res = (sum*cost).toFixed(2); jQuery(".minus_" + index).parent().closest('tr').find(".rb_total").html(res); var all_sum = 0; jQuery("tbody tr.rb_item .rb_total").each(function(){ all_sum += parseFloat(jQuery(this).text()); return all_sum; }); jQuery(".recycle_bin > tfoot > tr.all_price > td.rb_total strong").html(all_sum); var tmp1 = String(window.__cart.discount).split(";"); var max_discount_n = 0; for (property in tmp1) { var ti = String(tmp1[property]).split(':'); if (all_sum*1 > ti[0]) { if ((max_discount_n*1) < (ti[1]*1)) { max_discount_n = ti[1]; } } } if (max_discount_n*1 > 0) { if(jQuery(".recycle_bin > tfoot > tr.discount_row").length>0){jQuery(".recycle_bin > tfoot > tr.discount_row").show();}else{ jQuery(".recycle_bin > tfoot > tr.all_price").after(''+ ''+object_name.discont+' ' + max_discount_n + '%. '+object_name.full_total+''+ ''+ '' + ''); } var price_n = (all_sum / 100 * (100-max_discount_n)).toFixed(2); jQuery(".recycle_bin > tfoot > tr.discount_row > td.rb_total strong").html(price_n); jQuery(".recycle_bin > tfoot > tr.discount_row > td:first-child").html(''+object_name.discont+' ' + max_discount_n + '%. '+object_name.full_total+''); }else{jQuery(".recycle_bin > tfoot > tr.discount_row").hide();} var deliveryCost = (jQuery("select[name='select_delivery']").find('option:selected').attr('cost') * 1).toFixed(2); var deliveryCost1 = (jQuery("ul.custom_del li.select").find('> a.info').attr('cost') * 1).toFixed(2); if(jQuery("select[name='select_delivery']").length > 0) { if (price_n>0){ var del_price = price_n*1 + deliveryCost*1; }else{ var del_price = all_sum*1 + deliveryCost*1; } jQuery("#delivery_cost_total").text(del_price); } if(jQuery("ul.custom_del").length > 0) { if (price_n>0){ var del_price = price_n*1 + deliveryCost1*1; }else{ var del_price = all_sum*1 + deliveryCost1*1; } jQuery("#delivery_cost_total").text(del_price); } jQuery(".input_" + index).val(sum); } this.init(); this.update(); } function addtocart(id, key, href, cost, num, cnt, sklad) { if (num <=0){num=1;} var result = sklad - num; if(sklad==''||result>=0){ var name = jQuery("[name='wpshop-good-title-" + id + "']").val(); if (name == null){var name = jQuery('a.custom_add_'+ cnt).attr('name');} var properties = []; jQuery('#wpshop_property_'+id).find('input,select,textarea').each(function(index,obj) { properties.push(jQuery(obj).attr('name') + ': ' + jQuery(obj).val()); }); if (properties.length > 0) { name = name + '
(' + properties.join(', ') + ')'; } var jWpField = jQuery('[for="wpshop-wpfield"]'); if (jWpField.html() != null) { if (jQuery('#wpshop-wpfield').val().length > 0) { var wpfield = jWpField.html() + ": " + jQuery('#wpshop-wpfield').val(); name = name + "
" + wpfield; } } var t = jQuery('[name="goods_count_' + id + "_" + cnt + '"]'); window.__cart.add(id, key, name, href, cost, num, t.val(),sklad); }else{alert(object_name.stock_error);} } function button_effect() { jQuery(".wpshop_animate_icon").mouseover(function() { jQuery(this).animate({"background-color": '#6B8DB1'}, 200 ); }); jQuery(".wpshop_animate_icon").mouseout(function() { jQuery(this).animate({"background-color": '#C4D2E1'}, 200 ); }); } function WebForm_TextBoxKeyHandler(event) { if (event.keyCode == 13) { var target; target = event.srcElement; if ((typeof(target) != "undefined") && (target != null)) { if (typeof(target.onchange) != "undefined") { target.onchange(); event.cancelBubble = true; if (event.stopPropagation) event.stopPropagation(); return false; } } } return true; } jQuery(function() { if (jQuery('.wpshop_bag').find('.wpshop_good_price').css('display') == 'none') { jQuery('.wpshop_bag').hover( function() { jQuery(this).find('.wpshop_good_price').css('display','block'); }, function() { jQuery(this).find('.wpshop_good_price').css('display','none'); }); } button_effect(); }); //---------- }