woocommerce/assets/js/admin/write-panels.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

jQuery(function(e){e("#upsell_product_data").bind("keypress",function(h){if(h.keyCode==13){return false}});e("ul.tabs").show();e("div.panel-wrap").each(function(){e("div.panel:not(div.panel:first)",this).hide()});e("ul.tabs a").click(function(){var h=e(this).closest("div.panel-wrap");e("ul.tabs li",h).removeClass("active");e(this).parent().addClass("active");e("div.panel",h).hide();e(e(this).attr("href")).show();return false});e("a.edit_address").click(function(){e(this).hide();e(this).closest(".order_data").find("div.address").hide();e(this).closest(".order_data").find("div.edit_address").show()});jQuery("select.chosen_select").chosen();jQuery("select.chosen_select_nostd").chosen({allow_single_deselect:"true"});e("#order_items_list button.remove_row").live("click",function(){var h=confirm(woocommerce_writepanel_params.remove_item_notice);if(h){e(this).closest("tr.item").hide();e("input",e(this).closest("tr.item")).val("")}return false});e("button.calc_totals").live("click",function(){var r=confirm(woocommerce_writepanel_params.cart_total);if(r){var j=e("#order_items_list tr.item").size();var p=0;var q=e("input#_order_discount").val();var h=e("input#_order_shipping").val();var l=parseFloat(e("input#_order_shipping_tax").val());var m=0;var k=0;var p=0;var o=0;var n=0;if(!q){q=0}if(!h){h=0}if(!l){l=0}if(j>0){for(i=0;i<j;i++){itemCost=e("input[name^=item_cost]:eq("+i+")").val();itemQty=parseInt(e("input[name^=item_quantity]:eq("+i+")").val());itemBase=e("input[name^=base_item_cost]:eq("+i+")").val();itemTax=e("input[name^=item_tax_rate]:eq("+i+")").val();if(!itemCost){itemCost=0}if(!itemTax){itemTax=0}if(!itemQty){itemQty=0}if(!itemBase){itemBase=0}totalItemTax=0;if(itemTax&&itemTax>0){if(woocommerce_writepanel_params.prices_include_tax=="yes"){taxRate=(itemTax/100)+1;itemDiscount=((itemBase*itemQty)*taxRate)-((itemCost*itemQty)*taxRate);totalItemTax=(itemCost*itemQty)*(itemTax/100);discounted_price=(itemCost*itemQty)*taxRate;if(woocommerce_writepanel_params.round_at_subtotal=="no"){totalItemTax=totalItemTax*100;totalItemTax=totalItemTax.toFixed(2);totalItemTax=Math.round(totalItemTax)/100}}else{taxRate=(itemTax/100);itemDiscount=(itemBase*itemQty)-(itemCost*itemQty);totalItemTax=(itemCost*itemQty)*taxRate;discounted_price=(itemCost*itemQty)+totalItemTax;if(woocommerce_writepanel_params.round_at_subtotal=="no"){totalItemTax=totalItemTax*100;totalItemTax=totalItemTax.toFixed(2);totalItemTax=Math.round(totalItemTax)/100}}}else{itemDiscount=(itemBase*itemQty)-(itemCost*itemQty);discounted_price=(itemCost*itemQty)}p=p+parseFloat((itemBase*itemQty));n=n+parseFloat(itemDiscount);totalItemCost=parseFloat(discounted_price);k=k+parseFloat(totalItemCost);m=m+parseFloat(totalItemTax)}}if(woocommerce_writepanel_params.round_at_subtotal=="yes"){m=m*100;m=m.toFixed(2);m=Math.round(m)/100}o=parseFloat(k)-parseFloat(q)+parseFloat(h)+parseFloat(l);p=p*100;p=p.toFixed(2);p=Math.round(p)/100;o=o*100;o=o.toFixed(2);o=Math.round(o)/100;if(o<0){o=0}e("input#_cart_discount").val(n.toFixed(2));e("input#_order_subtotal").val(p.toFixed(2));e("input#_order_tax").val(m.toFixed(2));e("input#_order_shipping_tax").val(l.toFixed(2));e("input#_order_total").val(o.toFixed(2))}return false});e("button.add_shop_order_item").click(function(){var k=e("select.add_item_id").val();if(k){e("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});var h=e("table.woocommerce_order_items tbody tr.item").size();var j={action:"woocommerce_add_order_item",item_to_add:e("select.add_item_id").val(),index:h,security:woocommerce_writepanel_params.add_order_item_nonce};e.post(woocommerce_writepanel_params.ajax_url,j,function(l){e("table.woocommerce_order_items tbody#order_items_list").append(l);e("table.woocommerce_order_items").unblock();e("select.add_item_id").css("border-color","").val("");jQuery(".tips").tipTip({attribute:"tip",fadeIn:50,fadeOut:50})})}else{e("select.add_item_id").css("border-color","red")}});e("button.add_meta").live("