diff --git a/assets/js/admin/meta-boxes-order.js b/assets/js/admin/meta-boxes-order.js index 8ca68048d6f..d6eb1800d0c 100644 --- a/assets/js/admin/meta-boxes-order.js +++ b/assets/js/admin/meta-boxes-order.js @@ -600,7 +600,7 @@ jQuery( function ( $ ) { order_id: woocommerce_admin_meta_boxes.post_id, security: woocommerce_admin_meta_boxes.order_item_nonce }; - + $.ajax({ url: woocommerce_admin_meta_boxes.ajax_url, data: data, @@ -619,7 +619,9 @@ jQuery( function ( $ ) { // Refund actions $( 'body' ) .on( 'change', '.wc-order-refund-items #refund_amount', function () { - $( 'button .wc-order-refund-amount .amount' ).text( accounting.formatMoney( $( this ).val(), { + var total = accounting.unformat( $( this ).val(), woocommerce_admin.mon_decimal_point ); + + $( 'button .wc-order-refund-amount .amount' ).text( accounting.formatMoney( total, { symbol: woocommerce_admin_meta_boxes.currency_format_symbol, decimal: woocommerce_admin_meta_boxes.currency_format_decimal_sep, thousand: woocommerce_admin_meta_boxes.currency_format_thousand_sep, diff --git a/assets/js/admin/meta-boxes-order.min.js b/assets/js/admin/meta-boxes-order.min.js index ee0a6196fdd..92c619f8e3c 100644 --- a/assets/js/admin/meta-boxes-order.min.js +++ b/assets/js/admin/meta-boxes-order.min.js @@ -1 +1 @@ -jQuery(function(a){function b(){a("#woocommerce-order-items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}})}function c(){a("#woocommerce-order-items").unblock()}function d(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}function e(){var e={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}a("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),a("a.edit_address").click(function(b){b.preventDefault(),a(this).hide(),a(this).closest(".order_data_column").find("div.address").hide(),a(this).closest(".order_data_column").find("div.edit_address").show()}),a("#order_line_items tr, #order_fee_line_items tr").each(function(){a(this).trigger("init_row"),a(this).find(".edit").hide()}),a("body").on("init_row","#order_line_items tr.item",function(){var b=a(this),c=b.find("input.quantity"),d=c.val(),e=accounting.unformat(b.find("input.line_subtotal").val(),woocommerce_admin.mon_decimal_point),f=accounting.unformat(b.find("input.line_total").val(),woocommerce_admin.mon_decimal_point),g=accounting.unformat(b.find("input.line_tax").val(),woocommerce_admin.mon_decimal_point),h=accounting.unformat(b.find("input.line_subtotal_tax").val(),woocommerce_admin.mon_decimal_point);d?(unit_subtotal=parseFloat(accounting.toFixed(e/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_subtotal_tax=parseFloat(accounting.toFixed(h/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_total=parseFloat(accounting.toFixed(f/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_total_tax=parseFloat(accounting.toFixed(g/d,woocommerce_admin_meta_boxes.rounding_precision))):unit_subtotal=unit_subtotal_tax=unit_total=unit_total_tax=0,c.attr("data-o_qty",d),b.attr("data-unit_subtotal",unit_subtotal),b.attr("data-unit_subtotal_tax",unit_subtotal_tax),b.attr("data-unit_total",unit_total),b.attr("data-unit_total_tax",unit_total_tax)}).on("init_row","#order_fee_line_items tr.fee",function(){var b=a(this),c=accounting.unformat(b.find("input.line_total").val(),woocommerce_admin.mon_decimal_point),d=accounting.unformat(b.find("input.line_tax").val(),woocommerce_admin.mon_decimal_point);unit_total=parseFloat(accounting.toFixed(c,woocommerce_admin_meta_boxes.rounding_precision)),unit_total_tax=parseFloat(accounting.toFixed(d,woocommerce_admin_meta_boxes.rounding_precision)),b.attr("data-unit_total",unit_total),b.attr("data-unit_total_tax",unit_total_tax)}).on("click","a.edit-order-item",function(){return a(this).closest("tr").find(".view").hide(),a(this).closest("tr").find(".edit").show(),a(this).hide(),a("button.add-line-item").click(),a("button.cancel-action").attr("data-reload",!0),!1}).on("click",".woocommerce_order_items a.delete-order-item",function(){var d=window.confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(d){var e=a(this).closest("tr.item, tr.fee, tr.shipping"),f=e.attr("data-order_item_id");b();var g={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(){e.remove(),c()}})}return!1}).on("click","#order_refunds .delete_refund",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_refund)){var c=a(this).closest("tr.refund"),d=c.attr("data-order_refund_id");b();var f={action:"woocommerce_delete_refund",refund_id:d,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){e()}})}return!1}).on("change",".woocommerce_order_items input.quantity",function(){var b=a(this).closest("tr.item"),c=a(this).val(),d=b.attr("data-unit_subtotal"),e=b.attr("data-unit_subtotal_tax"),f=b.attr("data-unit_total"),g=b.attr("data-unit_total_tax"),h=(a(this).attr("data-o_qty"),parseFloat(accounting.formatNumber(d*c,woocommerce_admin_meta_boxes.rounding_precision,""))),i=parseFloat(accounting.formatNumber(e*c,woocommerce_admin_meta_boxes.rounding_precision,"")),j=parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")),k=parseFloat(accounting.formatNumber(g*c,woocommerce_admin_meta_boxes.rounding_precision,""));h=h.toString().replace(".",woocommerce_admin.mon_decimal_point),i=i.toString().replace(".",woocommerce_admin.mon_decimal_point),j=j.toString().replace(".",woocommerce_admin.mon_decimal_point),k=k.toString().replace(".",woocommerce_admin.mon_decimal_point),b.find("input.line_subtotal").val(h),b.find("input.line_total").val(j),b.find("input.line_subtotal_tax").val(i),b.find("input.line_tax").val(k),a(this).trigger("quantity_changed")}).on("change",".woocommerce_order_items input.line_subtotal",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_subtotal",e)}).on("change",".woocommerce_order_items input.line_total",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_total",e)}).on("change",".woocommerce_order_items input.line_subtotal_tax",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_subtotal_tax",e)}).on("change",".woocommerce_order_items input.line_tax",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_total_tax",e)}).on("change",".woocommerce_order_items .wc-order-item-refund-quantity input",function(){var b=0,c=a(".woocommerce_order_items").find("tr.item, tr.fee, tr.shipping");c.each(function(){var c=a(this),d=c.find(".wc-order-item-refund-quantity input").val();if(d){var e=a(this).find("input.line_total").val()||0;e=parseFloat(e),a(this).find("input.line_tax").each(function(){var b=a(this).val()||0;b=accounting.unformat(b,woocommerce_admin.mon_decimal_point),e+=parseFloat(b)}),b=parseFloat(b)+d*parseFloat(e)}}),a("#refund_amount").val(accounting.formatNumber(b,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change()}).on("click",".woocommerce_order_items button.add_order_item_meta",function(){var d=a(this),e=d.closest("tr.item"),f={order_item_id:e.attr("data-order_item_id"),action:"woocommerce_add_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};return b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(a){e.find("tbody.meta_items").append(a),c()}}),!1}).on("click",".woocommerce_order_items button.remove_order_item_meta",function(){var d=confirm(woocommerce_admin_meta_boxes.remove_item_meta);if(d){var e=a(this).closest("tr"),f={meta_id:e.attr("data-meta_id"),action:"woocommerce_remove_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){e.hide(),c()}})}return!1}),a("#woocommerce-order-items").on("click","button.add-line-item",function(){return a("div.wc-order-add-item").slideDown(),a("div.wc-order-bulk-actions").slideUp(),!1}).on("click","button.refund-items",function(){return a("div.wc-order-refund-items").slideDown(),a("div.wc-order-bulk-actions").slideUp(),a("div.wc-order-totals-items").slideUp(),a(".wc-order-item-refund-quantity").show(),a(".wc-order-edit-line-item").hide(),!1}).on("click",".cancel-action",function(){return a(this).closest("div.wc-order-data-row").slideUp(),a("div.wc-order-bulk-actions").slideDown(),a("div.wc-order-totals-items").slideDown(),a(".wc-order-item-refund-quantity").hide(),a(".wc-order-edit-line-item").show(),"true"===a(this).attr("data-reload")&&e(),!1}).on("click","button.add-order-item",function(){return a(this).WCBackboneModal({template:"#wc-modal-add-products"}),!1}).on("click","button.add-order-fee",function(){b();var d={action:"woocommerce_add_order_fee",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_fee_line_items").append(b),c()}),!1}).on("click","button.add-order-shipping",function(){b();var d={action:"woocommerce_add_order_shipping",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_shipping_line_items").append(b),c()}),!1}).on("click","button.add-order-tax",function(){return a(this).WCBackboneModal({template:"#wc-modal-add-tax"}),!1}).on("click","input.check-column",function(){a(this).is(":checked")?a("#woocommerce-order-items").find(".check-column input").attr("checked","checked"):a("#woocommerce-order-items").find(".check-column input").removeAttr("checked")}).on("click",".do_bulk_action",function(){var d=a(this).closest(".bulk-actions").find("select").val(),e=a("#woocommerce-order-items").find(".check-column input:checked"),f=[];if(a(e).each(function(){var b=a(this).closest("tr");b.attr("data-order_item_id")&&f.push(b.attr("data-order_item_id"))}),0==f.length)return void alert(woocommerce_admin_meta_boxes.i18n_select_items);if("delete"==d){var g=confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(g){b();var h={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:h,type:"POST",success:function(){a(e).each(function(){a(this).closest("tr").remove()}),c()}})}}else if("reduce_stock"==d){b();var i={};a(e).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");i[b.attr("data-order_item_id")]=c.val()});var h={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:f,order_item_qty:i,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:h,type:"POST",success:function(a){alert(a),c()}})}else if("increase_stock"==d){b();var i={};a(e).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");i[b.attr("data-order_item_id")]=c.val()});var h={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:f,order_item_qty:i,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:h,type:"POST",success:function(a){alert(a),c()}})}return!1}).on("click","button.calculate-action",function(){if(window.confirm(woocommerce_admin_meta_boxes.calc_totals)){b();var c=0,d=0,e=0,f=a("#_order_discount").val()||"0";f=accounting.unformat(f.replace(",",".")),a(".woocommerce_order_items tr.shipping input.line_total").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),e+=parseFloat(cost)}),a(".woocommerce_order_items input.line_tax").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),d+=parseFloat(cost)}),a(".woocommerce_order_items tr.item, .woocommerce_order_items tr.fee").each(function(){line_total=a(this).find("input.line_total").val()||"0",c+=accounting.unformat(line_total.replace(",","."))}),"yes"===woocommerce_admin_meta_boxes.round_at_subtotal&&(d=parseFloat(accounting.toFixed(d,woocommerce_admin_meta_boxes.rounding_precision))),a("#_order_total").val(accounting.formatNumber(c+d+e-f,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change(),a("button.save-action").click()}return!1}).on("click","button.save-action",function(){var e={order_id:woocommerce_admin_meta_boxes.post_id,items:a("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize(),action:"woocommerce_save_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};return b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}}),!1}).on("click","a.delete-order-tax",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_tax)){b();var e={action:"woocommerce_remote_order_tax",rate_id:a(this).attr("data-rate_id"),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}return!1}),a("body").on("change",".wc-order-refund-items #refund_amount",function(){a("button .wc-order-refund-amount .amount").text(accounting.formatMoney(a(this).val(),{symbol:woocommerce_admin_meta_boxes.currency_format_symbol,decimal:woocommerce_admin_meta_boxes.currency_format_decimal_sep,thousand:woocommerce_admin_meta_boxes.currency_format_thousand_sep,precision:woocommerce_admin_meta_boxes.currency_format_num_decimals,format:woocommerce_admin_meta_boxes.currency_format}))}).on("click",".wc-order-refund-items button.do-api-refund, .wc-order-refund-items button.do-manual-refund",function(){if(b(),window.confirm(woocommerce_admin_meta_boxes.i18n_do_refund)){var d=a("input#refund_amount").val(),f=a("input#refund_reason").val(),g=a.map(a("input[type=number][name^=order_item_refund_qty]"),function(b){var c=[];return c.push(a(b).closest("tr.item,tr.fee").data("order_item_id"),b.value),c}),h={action:"woocommerce_refund_line_items",order_id:woocommerce_admin_meta_boxes.post_id,refund_amount:d,refund_reason:f,refund_qty:JSON.stringify(g,null,""),api_refund:a(this).is(".do-api-refund"),security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,h,function(a){a===!0?e():a.error&&(window.alert(a.error),c())})}else c()}),a("#woocommerce-order-totals").on("click","button.calc_line_taxes",function(){a(".woocommerce_order_items_wrapper").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b=confirm(woocommerce_admin_meta_boxes.calc_line_taxes);if(b){var c=a(".woocommerce_order_items").find("tr.item, tr.fee"),d=a("#_shipping_country").val(),e=a("#_billing_country").val();if(d)var f=d,g=a("#_shipping_state").val(),h=a("#_shipping_postcode").val(),i=a("#_shipping_city").val();else if(e)var f=e,g=a("#_billing_state").val(),h=a("#_billing_postcode").val(),i=a("#_billing_city").val();else var f=woocommerce_admin_meta_boxes.base_country,g="",h="",i="";var j={};c.each(function(){var b=a(this),c=b.find("input.order_item_id").val(),d=b.find("input.line_subtotal").val(),e=b.find("input.line_total").val(),f=b.find("select.tax_class").val();j[c]={},j[c].line_subtotal=d,j[c].line_total=e,j[c].tax_class=f}),order_shipping=0,a("#shipping_rows").find("input[type=number], .wc_input_price").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),order_shipping+=parseFloat(cost)});var k={action:"woocommerce_calc_line_taxes",order_id:woocommerce_admin_meta_boxes.post_id,items:j,shipping:order_shipping,country:f,state:g,postcode:h,city:i,security:woocommerce_admin_meta_boxes.calc_totals_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,k,function(b){b&&(c.each(function(){var c=a(this),d=c.find("input.order_item_id").val();c.find(".edit-order-item").click(),b.item_taxes[d]&&(c.find("input.line_tax").val(b.item_taxes[d].line_tax).change(),c.find("input.line_subtotal_tax").val(b.item_taxes[d].line_subtotal_tax).change()),b.tax_row_html&&a("#tax_rows").empty().append(b.tax_row_html)}),a("#tax_rows").find("input").change()),a(".woocommerce_order_items_wrapper").unblock()})}else a(".woocommerce_order_items_wrapper").unblock();return!1}),a("body").on("wc_backbone_modal_response",function(e,f){if("#wc-modal-add-products"===f){var g=a("select#add_item_id").val();g?(count=g.length,b(),a.each(g,function(b,e){var f={action:"woocommerce_add_order_item",item_to_add:e,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,f,function(b){a("table.woocommerce_order_items tbody#order_line_items").append(b),--count||(a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","").val(""),d(),a("select#add_item_id").trigger("chosen:updated"),c()),a("#order_line_items tr.new_row").trigger("init_row").removeClass("new_row")})})):a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","red")}}),a("body").on("wc_backbone_modal_response",function(e,f){if("#wc-modal-add-tax"===f){b();var g={action:"woocommerce_add_order_tax",rate_id:a("#add-order-tax").val(),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}}),a("span.inline_total").closest(".totals_group").find("input").change(),a(".order_download_permissions").on("click","button.grant_access",function(){var b=a("select#grant_access_id").val();if(b){a(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_grant_access_to_download",product_ids:b,loop:a(".order_download_permissions .wc-metabox").size(),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(b){b?a(".order_download_permissions .wc-metaboxes").append(b):alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),a(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0}),a("#grant_access_id").val("").trigger("chosen:updated"),a(".order_download_permissions").unblock()}),!1}}).on("click","button.revoke_access",function(b){b.preventDefault();var c=confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke);if(c){var d=a(this).parent().parent(),e=a(this).attr("rel").split(",")[0],f=a(this).attr("rel").split(",")[1];if(e>0){a(d).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var g={action:"woocommerce_revoke_access_to_download",product_id:e,download_id:f,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,g,function(){a(d).fadeOut("300",function(){a(d).remove()})})}else a(d).fadeOut("300",function(){a(d).remove()})}return!1}),a("button.load_customer_billing").click(function(){var b=confirm(woocommerce_admin_meta_boxes.load_billing);if(b){var c=a("#customer_user").val();if(!c)return alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var d={user_id:c,type_to_load:"billing",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){var c=b;c&&(a("input#_billing_first_name").val(c.billing_first_name),a("input#_billing_last_name").val(c.billing_last_name),a("input#_billing_company").val(c.billing_company),a("input#_billing_address_1").val(c.billing_address_1),a("input#_billing_address_2").val(c.billing_address_2),a("input#_billing_city").val(c.billing_city),a("input#_billing_postcode").val(c.billing_postcode),a("#_billing_country").val(c.billing_country),a("input#_billing_state").val(c.billing_state),a("input#_billing_email").val(c.billing_email),a("input#_billing_phone").val(c.billing_phone)),a(".edit_address").unblock()}})}return!1}),a("button.load_customer_shipping").click(function(){var b=confirm(woocommerce_admin_meta_boxes.load_shipping);if(b){var c=a("#customer_user").val();if(!c)return alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var d={user_id:c,type_to_load:"shipping",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){var c=b;c&&(a("input#_shipping_first_name").val(c.shipping_first_name),a("input#_shipping_last_name").val(c.shipping_last_name),a("input#_shipping_company").val(c.shipping_company),a("input#_shipping_address_1").val(c.shipping_address_1),a("input#_shipping_address_2").val(c.shipping_address_2),a("input#_shipping_city").val(c.shipping_city),a("input#_shipping_postcode").val(c.shipping_postcode),a("#_shipping_country").val(c.shipping_country),a("input#_shipping_state").val(c.shipping_state)),a(".edit_address").unblock()}})}return!1}),a("button.billing-same-as-shipping").click(function(){var b=confirm(woocommerce_admin_meta_boxes.copy_billing);return b&&(a("input#_shipping_first_name").val(a("input#_billing_first_name").val()),a("input#_shipping_last_name").val(a("input#_billing_last_name").val()),a("input#_shipping_company").val(a("input#_billing_company").val()),a("input#_shipping_address_1").val(a("input#_billing_address_1").val()),a("input#_shipping_address_2").val(a("input#_billing_address_2").val()),a("input#_shipping_city").val(a("input#_billing_city").val()),a("input#_shipping_postcode").val(a("input#_billing_postcode").val()),a("#_shipping_country").val(a("#_billing_country").val()),a("input#_shipping_state").val(a("input#_billing_state").val())),!1}),a(".totals_group").on("click","a.add_total_row",function(){return a(this).closest(".totals_group").find(".total_rows").append(a(this).data("row")),!1}),a(".total_rows").on("click","a.delete_total_row",function(){$row=a(this).closest(".total_row");var b=$row.attr("data-order_item_id");return b?$row.append('').hide():$row.remove(),!1}),a("#woocommerce-order-notes").on("click","a.add_note",function(){if(a("textarea#add_order_note").val()){a("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:a("textarea#add_order_note").val(),note_type:a("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,b,function(b){a("ul.order_notes").prepend(b),a("#woocommerce-order-notes").unblock(),a("#add_order_note").val("")}),!1}}).on("click","a.delete_note",function(){var b=a(this).closest("li.note");a(b).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_delete_order_note",note_id:a(b).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(){a(b).remove()}),!1})}); \ No newline at end of file +jQuery(function(a){function b(){a("#woocommerce-order-items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}})}function c(){a("#woocommerce-order-items").unblock()}function d(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}function e(){var e={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}a("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),a("a.edit_address").click(function(b){b.preventDefault(),a(this).hide(),a(this).closest(".order_data_column").find("div.address").hide(),a(this).closest(".order_data_column").find("div.edit_address").show()}),a("#order_line_items tr, #order_fee_line_items tr").each(function(){a(this).trigger("init_row"),a(this).find(".edit").hide()}),a("body").on("init_row","#order_line_items tr.item",function(){var b=a(this),c=b.find("input.quantity"),d=c.val(),e=accounting.unformat(b.find("input.line_subtotal").val(),woocommerce_admin.mon_decimal_point),f=accounting.unformat(b.find("input.line_total").val(),woocommerce_admin.mon_decimal_point),g=accounting.unformat(b.find("input.line_tax").val(),woocommerce_admin.mon_decimal_point),h=accounting.unformat(b.find("input.line_subtotal_tax").val(),woocommerce_admin.mon_decimal_point);d?(unit_subtotal=parseFloat(accounting.toFixed(e/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_subtotal_tax=parseFloat(accounting.toFixed(h/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_total=parseFloat(accounting.toFixed(f/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_total_tax=parseFloat(accounting.toFixed(g/d,woocommerce_admin_meta_boxes.rounding_precision))):unit_subtotal=unit_subtotal_tax=unit_total=unit_total_tax=0,c.attr("data-o_qty",d),b.attr("data-unit_subtotal",unit_subtotal),b.attr("data-unit_subtotal_tax",unit_subtotal_tax),b.attr("data-unit_total",unit_total),b.attr("data-unit_total_tax",unit_total_tax)}).on("init_row","#order_fee_line_items tr.fee",function(){var b=a(this),c=accounting.unformat(b.find("input.line_total").val(),woocommerce_admin.mon_decimal_point),d=accounting.unformat(b.find("input.line_tax").val(),woocommerce_admin.mon_decimal_point);unit_total=parseFloat(accounting.toFixed(c,woocommerce_admin_meta_boxes.rounding_precision)),unit_total_tax=parseFloat(accounting.toFixed(d,woocommerce_admin_meta_boxes.rounding_precision)),b.attr("data-unit_total",unit_total),b.attr("data-unit_total_tax",unit_total_tax)}).on("click","a.edit-order-item",function(){return a(this).closest("tr").find(".view").hide(),a(this).closest("tr").find(".edit").show(),a(this).hide(),a("button.add-line-item").click(),a("button.cancel-action").attr("data-reload",!0),!1}).on("click",".woocommerce_order_items a.delete-order-item",function(){var d=window.confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(d){var e=a(this).closest("tr.item, tr.fee, tr.shipping"),f=e.attr("data-order_item_id");b();var g={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(){e.remove(),c()}})}return!1}).on("click","#order_refunds .delete_refund",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_refund)){var c=a(this).closest("tr.refund"),d=c.attr("data-order_refund_id");b();var f={action:"woocommerce_delete_refund",refund_id:d,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){e()}})}return!1}).on("change",".woocommerce_order_items input.quantity",function(){var b=a(this).closest("tr.item"),c=a(this).val(),d=b.attr("data-unit_subtotal"),e=b.attr("data-unit_subtotal_tax"),f=b.attr("data-unit_total"),g=b.attr("data-unit_total_tax"),h=(a(this).attr("data-o_qty"),parseFloat(accounting.formatNumber(d*c,woocommerce_admin_meta_boxes.rounding_precision,""))),i=parseFloat(accounting.formatNumber(e*c,woocommerce_admin_meta_boxes.rounding_precision,"")),j=parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")),k=parseFloat(accounting.formatNumber(g*c,woocommerce_admin_meta_boxes.rounding_precision,""));h=h.toString().replace(".",woocommerce_admin.mon_decimal_point),i=i.toString().replace(".",woocommerce_admin.mon_decimal_point),j=j.toString().replace(".",woocommerce_admin.mon_decimal_point),k=k.toString().replace(".",woocommerce_admin.mon_decimal_point),b.find("input.line_subtotal").val(h),b.find("input.line_total").val(j),b.find("input.line_subtotal_tax").val(i),b.find("input.line_tax").val(k),a(this).trigger("quantity_changed")}).on("change",".woocommerce_order_items input.line_subtotal",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_subtotal",e)}).on("change",".woocommerce_order_items input.line_total",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_total",e)}).on("change",".woocommerce_order_items input.line_subtotal_tax",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_subtotal_tax",e)}).on("change",".woocommerce_order_items input.line_tax",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_total_tax",e)}).on("change",".woocommerce_order_items .wc-order-item-refund-quantity input",function(){var b=0,c=a(".woocommerce_order_items").find("tr.item, tr.fee, tr.shipping");c.each(function(){var c=a(this),d=c.find(".wc-order-item-refund-quantity input").val();if(d){var e=a(this).find("input.line_total").val()||0;e=parseFloat(e),a(this).find("input.line_tax").each(function(){var b=a(this).val()||0;b=accounting.unformat(b,woocommerce_admin.mon_decimal_point),e+=parseFloat(b)}),b=parseFloat(b)+d*parseFloat(e)}}),a("#refund_amount").val(accounting.formatNumber(b,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change()}).on("click",".woocommerce_order_items button.add_order_item_meta",function(){var d=a(this),e=d.closest("tr.item"),f={order_item_id:e.attr("data-order_item_id"),action:"woocommerce_add_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};return b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(a){e.find("tbody.meta_items").append(a),c()}}),!1}).on("click",".woocommerce_order_items button.remove_order_item_meta",function(){var d=confirm(woocommerce_admin_meta_boxes.remove_item_meta);if(d){var e=a(this).closest("tr"),f={meta_id:e.attr("data-meta_id"),action:"woocommerce_remove_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){e.hide(),c()}})}return!1}),a("#woocommerce-order-items").on("click","button.add-line-item",function(){return a("div.wc-order-add-item").slideDown(),a("div.wc-order-bulk-actions").slideUp(),!1}).on("click","button.refund-items",function(){return a("div.wc-order-refund-items").slideDown(),a("div.wc-order-bulk-actions").slideUp(),a("div.wc-order-totals-items").slideUp(),a(".wc-order-item-refund-quantity").show(),a(".wc-order-edit-line-item").hide(),!1}).on("click",".cancel-action",function(){return a(this).closest("div.wc-order-data-row").slideUp(),a("div.wc-order-bulk-actions").slideDown(),a("div.wc-order-totals-items").slideDown(),a(".wc-order-item-refund-quantity").hide(),a(".wc-order-edit-line-item").show(),"true"===a(this).attr("data-reload")&&e(),!1}).on("click","button.add-order-item",function(){return a(this).WCBackboneModal({template:"#wc-modal-add-products"}),!1}).on("click","button.add-order-fee",function(){b();var d={action:"woocommerce_add_order_fee",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_fee_line_items").append(b),c()}),!1}).on("click","button.add-order-shipping",function(){b();var d={action:"woocommerce_add_order_shipping",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_shipping_line_items").append(b),c()}),!1}).on("click","button.add-order-tax",function(){return a(this).WCBackboneModal({template:"#wc-modal-add-tax"}),!1}).on("click","input.check-column",function(){a(this).is(":checked")?a("#woocommerce-order-items").find(".check-column input").attr("checked","checked"):a("#woocommerce-order-items").find(".check-column input").removeAttr("checked")}).on("click",".do_bulk_action",function(){var d=a(this).closest(".bulk-actions").find("select").val(),e=a("#woocommerce-order-items").find(".check-column input:checked"),f=[];if(a(e).each(function(){var b=a(this).closest("tr");b.attr("data-order_item_id")&&f.push(b.attr("data-order_item_id"))}),0==f.length)return void alert(woocommerce_admin_meta_boxes.i18n_select_items);if("delete"==d){var g=confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(g){b();var h={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:h,type:"POST",success:function(){a(e).each(function(){a(this).closest("tr").remove()}),c()}})}}else if("reduce_stock"==d){b();var i={};a(e).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");i[b.attr("data-order_item_id")]=c.val()});var h={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:f,order_item_qty:i,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:h,type:"POST",success:function(a){alert(a),c()}})}else if("increase_stock"==d){b();var i={};a(e).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");i[b.attr("data-order_item_id")]=c.val()});var h={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:f,order_item_qty:i,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:h,type:"POST",success:function(a){alert(a),c()}})}return!1}).on("click","button.calculate-action",function(){if(window.confirm(woocommerce_admin_meta_boxes.calc_totals)){b();var c=0,d=0,e=0,f=a("#_order_discount").val()||"0";f=accounting.unformat(f.replace(",",".")),a(".woocommerce_order_items tr.shipping input.line_total").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),e+=parseFloat(cost)}),a(".woocommerce_order_items input.line_tax").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),d+=parseFloat(cost)}),a(".woocommerce_order_items tr.item, .woocommerce_order_items tr.fee").each(function(){line_total=a(this).find("input.line_total").val()||"0",c+=accounting.unformat(line_total.replace(",","."))}),"yes"===woocommerce_admin_meta_boxes.round_at_subtotal&&(d=parseFloat(accounting.toFixed(d,woocommerce_admin_meta_boxes.rounding_precision))),a("#_order_total").val(accounting.formatNumber(c+d+e-f,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change(),a("button.save-action").click()}return!1}).on("click","button.save-action",function(){var e={order_id:woocommerce_admin_meta_boxes.post_id,items:a("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize(),action:"woocommerce_save_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};return b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}}),!1}).on("click","a.delete-order-tax",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_tax)){b();var e={action:"woocommerce_remote_order_tax",rate_id:a(this).attr("data-rate_id"),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}return!1}),a("body").on("change",".wc-order-refund-items #refund_amount",function(){var b=accounting.unformat(a(this).val(),woocommerce_admin.mon_decimal_point);a("button .wc-order-refund-amount .amount").text(accounting.formatMoney(b,{symbol:woocommerce_admin_meta_boxes.currency_format_symbol,decimal:woocommerce_admin_meta_boxes.currency_format_decimal_sep,thousand:woocommerce_admin_meta_boxes.currency_format_thousand_sep,precision:woocommerce_admin_meta_boxes.currency_format_num_decimals,format:woocommerce_admin_meta_boxes.currency_format}))}).on("click",".wc-order-refund-items button.do-api-refund, .wc-order-refund-items button.do-manual-refund",function(){if(b(),window.confirm(woocommerce_admin_meta_boxes.i18n_do_refund)){var d=a("input#refund_amount").val(),f=a("input#refund_reason").val(),g=a.map(a("input[type=number][name^=order_item_refund_qty]"),function(b){var c=[];return c.push(a(b).closest("tr.item,tr.fee").data("order_item_id"),b.value),c}),h={action:"woocommerce_refund_line_items",order_id:woocommerce_admin_meta_boxes.post_id,refund_amount:d,refund_reason:f,refund_qty:JSON.stringify(g,null,""),api_refund:a(this).is(".do-api-refund"),security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,h,function(a){a===!0?e():a.error&&(window.alert(a.error),c())})}else c()}),a("#woocommerce-order-totals").on("click","button.calc_line_taxes",function(){a(".woocommerce_order_items_wrapper").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b=confirm(woocommerce_admin_meta_boxes.calc_line_taxes);if(b){var c=a(".woocommerce_order_items").find("tr.item, tr.fee"),d=a("#_shipping_country").val(),e=a("#_billing_country").val();if(d)var f=d,g=a("#_shipping_state").val(),h=a("#_shipping_postcode").val(),i=a("#_shipping_city").val();else if(e)var f=e,g=a("#_billing_state").val(),h=a("#_billing_postcode").val(),i=a("#_billing_city").val();else var f=woocommerce_admin_meta_boxes.base_country,g="",h="",i="";var j={};c.each(function(){var b=a(this),c=b.find("input.order_item_id").val(),d=b.find("input.line_subtotal").val(),e=b.find("input.line_total").val(),f=b.find("select.tax_class").val();j[c]={},j[c].line_subtotal=d,j[c].line_total=e,j[c].tax_class=f}),order_shipping=0,a("#shipping_rows").find("input[type=number], .wc_input_price").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),order_shipping+=parseFloat(cost)});var k={action:"woocommerce_calc_line_taxes",order_id:woocommerce_admin_meta_boxes.post_id,items:j,shipping:order_shipping,country:f,state:g,postcode:h,city:i,security:woocommerce_admin_meta_boxes.calc_totals_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,k,function(b){b&&(c.each(function(){var c=a(this),d=c.find("input.order_item_id").val();c.find(".edit-order-item").click(),b.item_taxes[d]&&(c.find("input.line_tax").val(b.item_taxes[d].line_tax).change(),c.find("input.line_subtotal_tax").val(b.item_taxes[d].line_subtotal_tax).change()),b.tax_row_html&&a("#tax_rows").empty().append(b.tax_row_html)}),a("#tax_rows").find("input").change()),a(".woocommerce_order_items_wrapper").unblock()})}else a(".woocommerce_order_items_wrapper").unblock();return!1}),a("body").on("wc_backbone_modal_response",function(e,f){if("#wc-modal-add-products"===f){var g=a("select#add_item_id").val();g?(count=g.length,b(),a.each(g,function(b,e){var f={action:"woocommerce_add_order_item",item_to_add:e,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,f,function(b){a("table.woocommerce_order_items tbody#order_line_items").append(b),--count||(a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","").val(""),d(),a("select#add_item_id").trigger("chosen:updated"),c()),a("#order_line_items tr.new_row").trigger("init_row").removeClass("new_row")})})):a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","red")}}),a("body").on("wc_backbone_modal_response",function(e,f){if("#wc-modal-add-tax"===f){b();var g={action:"woocommerce_add_order_tax",rate_id:a("#add-order-tax").val(),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}}),a("span.inline_total").closest(".totals_group").find("input").change(),a(".order_download_permissions").on("click","button.grant_access",function(){var b=a("select#grant_access_id").val();if(b){a(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_grant_access_to_download",product_ids:b,loop:a(".order_download_permissions .wc-metabox").size(),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(b){b?a(".order_download_permissions .wc-metaboxes").append(b):alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),a(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0}),a("#grant_access_id").val("").trigger("chosen:updated"),a(".order_download_permissions").unblock()}),!1}}).on("click","button.revoke_access",function(b){b.preventDefault();var c=confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke);if(c){var d=a(this).parent().parent(),e=a(this).attr("rel").split(",")[0],f=a(this).attr("rel").split(",")[1];if(e>0){a(d).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var g={action:"woocommerce_revoke_access_to_download",product_id:e,download_id:f,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,g,function(){a(d).fadeOut("300",function(){a(d).remove()})})}else a(d).fadeOut("300",function(){a(d).remove()})}return!1}),a("button.load_customer_billing").click(function(){var b=confirm(woocommerce_admin_meta_boxes.load_billing);if(b){var c=a("#customer_user").val();if(!c)return alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var d={user_id:c,type_to_load:"billing",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){var c=b;c&&(a("input#_billing_first_name").val(c.billing_first_name),a("input#_billing_last_name").val(c.billing_last_name),a("input#_billing_company").val(c.billing_company),a("input#_billing_address_1").val(c.billing_address_1),a("input#_billing_address_2").val(c.billing_address_2),a("input#_billing_city").val(c.billing_city),a("input#_billing_postcode").val(c.billing_postcode),a("#_billing_country").val(c.billing_country),a("input#_billing_state").val(c.billing_state),a("input#_billing_email").val(c.billing_email),a("input#_billing_phone").val(c.billing_phone)),a(".edit_address").unblock()}})}return!1}),a("button.load_customer_shipping").click(function(){var b=confirm(woocommerce_admin_meta_boxes.load_shipping);if(b){var c=a("#customer_user").val();if(!c)return alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var d={user_id:c,type_to_load:"shipping",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){var c=b;c&&(a("input#_shipping_first_name").val(c.shipping_first_name),a("input#_shipping_last_name").val(c.shipping_last_name),a("input#_shipping_company").val(c.shipping_company),a("input#_shipping_address_1").val(c.shipping_address_1),a("input#_shipping_address_2").val(c.shipping_address_2),a("input#_shipping_city").val(c.shipping_city),a("input#_shipping_postcode").val(c.shipping_postcode),a("#_shipping_country").val(c.shipping_country),a("input#_shipping_state").val(c.shipping_state)),a(".edit_address").unblock()}})}return!1}),a("button.billing-same-as-shipping").click(function(){var b=confirm(woocommerce_admin_meta_boxes.copy_billing);return b&&(a("input#_shipping_first_name").val(a("input#_billing_first_name").val()),a("input#_shipping_last_name").val(a("input#_billing_last_name").val()),a("input#_shipping_company").val(a("input#_billing_company").val()),a("input#_shipping_address_1").val(a("input#_billing_address_1").val()),a("input#_shipping_address_2").val(a("input#_billing_address_2").val()),a("input#_shipping_city").val(a("input#_billing_city").val()),a("input#_shipping_postcode").val(a("input#_billing_postcode").val()),a("#_shipping_country").val(a("#_billing_country").val()),a("input#_shipping_state").val(a("input#_billing_state").val())),!1}),a(".totals_group").on("click","a.add_total_row",function(){return a(this).closest(".totals_group").find(".total_rows").append(a(this).data("row")),!1}),a(".total_rows").on("click","a.delete_total_row",function(){$row=a(this).closest(".total_row");var b=$row.attr("data-order_item_id");return b?$row.append('').hide():$row.remove(),!1}),a("#woocommerce-order-notes").on("click","a.add_note",function(){if(a("textarea#add_order_note").val()){a("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:a("textarea#add_order_note").val(),note_type:a("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,b,function(b){a("ul.order_notes").prepend(b),a("#woocommerce-order-notes").unblock(),a("#add_order_note").val("")}),!1}}).on("click","a.delete_note",function(){var b=a(this).closest("li.note");a(b).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_delete_order_note",note_id:a(b).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(){a(b).remove()}),!1})}); \ No newline at end of file