2011-11-25 22:36:02 +00:00
|
|
|
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());itemDiscount=e("input[name^=item_discount]: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(!itemDiscount){itemDiscount=0}totalItemTax=0;n=n+itemDiscount;if(itemTax&&itemTax>0){if(woocommerce_writepanel_params.prices_include_tax=="yes"){taxRate=(itemTax/100)+1;price_in_tax=(itemCost*taxRate)*itemQty;discounted_price=price_in_tax-itemDiscount;totalItemTax=(discounted_price-(discounted_price/taxRate))*100;totalItemTax=totalItemTax.toFixed(2);totalItemTax=Math.round(totalItemTax)/100;discounted_price=discounted_price-totalItemTax}else{taxRate=(itemTax/100);discounted_price=(itemCost*taxRate)-itemDiscount;totalItemTax=(discounted_price*taxRate)*100;totalItemTax=totalItemTax.toFixed(2);totalItemTax=Math.round(totalItemTax)/100}}else{discounted_price=(itemCost*itemQty)-itemDiscount}totalItemCost=parseFloat(discounted_price);k=parseFloat(k+totalItemCost);p=parseFloat(p+(itemCost*itemQty));m=parseFloat(m+totalItemTax)}}o=parseFloat(k)+parseFloat(m)-parseFloat(q)+parseFloat(h)+parseFloat(l);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("");e(".tips").easyTooltip()})}else{e("select.add_item_id").css("border-color","red")}});e("button.add_meta").live("click",function(){var h=e(this).closest("tr.item").attr("rel");e(this).closest("table.meta").find(".meta_items").append('<tr><td><input type="text" name="meta_name['+h+'][]" placeholder="'+woocommerce_writepanel_params.meta_name+'" /></td><td><input type="text" name="meta_value['+h+'][]" placeholder="'+woocommerce_writepanel_params.meta_value+'" /></td><td><button class="remove_meta button">×</button></td></tr>');return false});e("but
|