From 04e8fbcb5ecc03054114f65c015c7ead40d65faa Mon Sep 17 00:00:00 2001 From: claudiosmweb Date: Wed, 16 Jul 2014 15:11:48 -0300 Subject: [PATCH] added new add products order items action --- assets/js/admin/meta-boxes-order.js | 129 +++++++++++------- assets/js/admin/meta-boxes-order.min.js | 2 +- assets/js/admin/meta-boxes.js | 109 +++++++++------ assets/js/admin/meta-boxes.min.js | 2 +- assets/js/admin/order-backbone-modal.js | 4 +- assets/js/admin/order-backbone-modal.min.js | 2 +- .../class-wc-meta-box-order-items.php | 27 +++- 7 files changed, 171 insertions(+), 104 deletions(-) diff --git a/assets/js/admin/meta-boxes-order.js b/assets/js/admin/meta-boxes-order.js index 0941ac20d9d..e8f97759638 100644 --- a/assets/js/admin/meta-boxes-order.js +++ b/assets/js/admin/meta-boxes-order.js @@ -1,15 +1,15 @@ -jQuery( function($){ +jQuery( function ( $ ) { // ORDERS - jQuery('#woocommerce-order-actions input, #woocommerce-order-actions a').click(function(){ + $( '#woocommerce-order-actions input, #woocommerce-order-actions a' ).click( function () { window.onbeforeunload = ''; }); - $('a.edit_address').click(function(event){ - $(this).hide(); - $(this).closest('.order_data_column').find('div.address').hide(); - $(this).closest('.order_data_column').find('div.edit_address').show(); - event.preventDefault(); + $( 'a.edit_address' ).click( function ( e ) { + e.preventDefault(); + $( this ).hide(); + $( this ).closest( '.order_data_column' ).find( 'div.address' ).hide(); + $( this ).closest( '.order_data_column' ).find( 'div.edit_address' ).show(); }); // When the page is loaded, store the unit costs @@ -160,7 +160,7 @@ jQuery( function($){ $items.each(function() { var $row = $(this); var refund_qty = $row.find( '.wc-order-item-refund-quantity input' ).val(); - + if ( refund_qty ) { refund_amount = parseFloat( refund_amount ) + ( refund_qty * ( parseFloat( $row.attr( 'data-unit_total' ) ) + parseFloat( $row.attr( 'data-unit_total_tax' ) ) ) ); } @@ -169,10 +169,10 @@ jQuery( function($){ $('#refund_amount').val( refund_amount ).change(); }) // Add some meta to a line item - .on('click', 'button.add_order_item_meta', function(){ + .on( 'click', 'button.add_order_item_meta', function () { - var $button = $(this); - var $item = $button.closest('tr.item'); + var $button = $( this ); + var $item = $button.closest( 'tr.item' ); var data = { order_item_id: $item.attr( 'data-order_item_id' ), @@ -219,7 +219,7 @@ jQuery( function($){ } ); } return false; - }); + }); $('#woocommerce-order-items') .on( 'click', 'button.add_line_item', function() { @@ -241,46 +241,10 @@ jQuery( function($){ $('.wc-order-edit-line-item').show(); return false; }) - .on( 'click', 'button.add_order_item', function() { - var add_item_ids = $('select#add_item_id').val(); - - if ( add_item_ids ) { - - count = add_item_ids.length; - - $('table.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: 0.6 } }); - - $.each( add_item_ids, function( index, value ) { - - var data = { - action: 'woocommerce_add_order_item', - item_to_add: value, - order_id: woocommerce_admin_meta_boxes.post_id, - security: woocommerce_admin_meta_boxes.order_item_nonce - }; - - $.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) { - - $('table.woocommerce_order_items tbody#order_items_list').append( response ); - - if (!--count) { - $('select#add_item_id, #add_item_id_chosen .chosen-choices').css('border-color', '').val(''); - - runTipTip(); - - $('select#add_item_id').trigger("chosen:updated"); - $('table.woocommerce_order_items').unblock(); - } - - $('#order_items_list tr.new_row').trigger('init_row').removeClass('new_row'); - }); - - }); - - } else { - $('select#add_item_id, #add_item_id_chosen .chosen-choices').css('border-color', 'red'); + .on( 'click', 'button.add_order_item', function () { + if ( window.WCBackbone.Modal.__instance === undefined ) { + window.WCBackbone.Modal.__instance = new WCBackbone.Modal.View({ target: '#wc-modal-add-products' }); } - return false; }) .on( 'click', 'button.add_order_fee', function() { $('table.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: 0.6 } }); @@ -642,6 +606,65 @@ jQuery( function($){ return false; }); + // Adds new products in order items + $( 'body' ).on( 'wc_backbone_modal_response', function ( e, target ) { + if ( '#wc-modal-add-products' !== target ) { + return; + } + + var add_item_ids = $( 'select#add_item_id' ).val(); + + if ( add_item_ids ) { + + count = add_item_ids.length; + + $( 'table.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: 0.6 + } + }); + + $.each( add_item_ids, function( index, value ) { + + var data = { + action: 'woocommerce_add_order_item', + item_to_add: value, + order_id: woocommerce_admin_meta_boxes.post_id, + security: woocommerce_admin_meta_boxes.order_item_nonce + }; + + $.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) { + + $( 'table.woocommerce_order_items tbody#order_items_list' ).append( response ); + + if ( !--count ) { + $( 'select#add_item_id, #add_item_id_chosen .chosen-choices' ).css( 'border-color', '' ).val( '' ); + + $( '#tiptip_holder' ).removeAttr( 'style' ); + $( '#tiptip_arrow' ).removeAttr( 'style' ); + $( '.tips' ).tipTip({ + 'attribute': 'data-tip', + 'fadeIn': 50, + 'fadeOut': 50, + 'delay': 200 + }); + + $( 'select#add_item_id' ).trigger( 'chosen:updated' ); + $( 'table.woocommerce_order_items' ).unblock(); + } + + $( '#order_items_list tr.new_row' ).trigger( 'init_row' ).removeClass( 'new_row' ); + }); + + }); + + } else { + $( 'select#add_item_id, #add_item_id_chosen .chosen-choices' ).css( 'border-color', 'red' ); + } + }); + $('span.inline_total').closest('.totals_group').find('input').change(); // Download permissions @@ -888,5 +911,5 @@ jQuery( function($){ }); return false; - }); -}); \ No newline at end of file + }); +}); diff --git a/assets/js/admin/meta-boxes-order.min.js b/assets/js/admin/meta-boxes-order.min.js index 3be80185f53..f5b842aac7c 100644 --- a/assets/js/admin/meta-boxes-order.min.js +++ b/assets/js/admin/meta-boxes-order.min.js @@ -1 +1 @@ -jQuery(function(a){jQuery("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),a("a.edit_address").click(function(b){a(this).hide(),a(this).closest(".order_data_column").find("div.address").hide(),a(this).closest(".order_data_column").find("div.edit_address").show(),b.preventDefault()}),a("#order_items_list tr.item, #order_items_list tr.fee").each(function(){a(this).trigger("init_row"),a(this).find(".edit").hide()}),a("#order_items_list").on("init_row","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","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(),!1}).on("click","a.delete_order_item",function(){var b=confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(b){var c=a(this).closest("tr.item, tr.fee"),d=c.attr("data-order_item_id");a("table.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}});var e={order_item_ids:d,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(){c.remove(),a("table.woocommerce_order_items").unblock()}})}return!1}).on("change","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","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","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","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","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",".wc-order-item-refund-quantity input",function(){var b=0,c=a("#order_items_list").find("tr.item, tr.fee");c.each(function(){var c=a(this),d=c.find(".wc-order-item-refund-quantity input").val();d&&(b=parseFloat(b)+d*(parseFloat(c.attr("data-unit_total"))+parseFloat(c.attr("data-unit_total_tax"))))}),a("#refund_amount").val(b).change()}).on("click","button.add_order_item_meta",function(){var b=a(this),c=b.closest("tr.item"),d={order_item_id:c.attr("data-order_item_id"),action:"woocommerce_add_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};return a("table.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}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){c.find("tbody.meta_items").append(b),a("table.woocommerce_order_items").unblock()}}),!1}).on("click","button.remove_order_item_meta",function(){var b=confirm(woocommerce_admin_meta_boxes.remove_item_meta);if(b){var c=a(this).closest("tr"),d={meta_id:c.attr("data-meta_id"),action:"woocommerce_remove_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};a("table.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}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(){c.hide(),a("table.woocommerce_order_items").unblock()}})}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(".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(".wc-order-item-refund-quantity").hide(),a(".wc-order-edit-line-item").show(),!1}).on("click","button.add_order_item",function(){var b=a("select#add_item_id").val();return b?(count=b.length,a("table.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}}),a.each(b,function(b,c){var d={action:"woocommerce_add_order_item",item_to_add:c,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_items_list").append(b),--count||(a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","").val(""),runTipTip(),a("select#add_item_id").trigger("chosen:updated"),a("table.woocommerce_order_items").unblock()),a("#order_items_list tr.new_row").trigger("init_row").removeClass("new_row")})})):a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","red"),!1}).on("click","button.add_order_fee",function(){a("table.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}});var b={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,b,function(b){a("table.woocommerce_order_items tbody#order_items_list").append(b),a("table.woocommerce_order_items").unblock()}),!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 b=a(this).closest(".bulk_actions").find("select").val(),c=a("#woocommerce-order-items").find(".check-column input:checked"),d=[];if(a(c).each(function(){var b=a(this).closest("tr.item, tr.fee");d.push(b.attr("data-order_item_id"))}),0==d.length)return void alert(woocommerce_admin_meta_boxes.i18n_select_items);if("delete"==b){var e=confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(e){a("table.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}});var f={order_item_ids:d,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){a(c).each(function(){a(this).closest("tr.item, tr.fee").remove()}),a("table.woocommerce_order_items").unblock()}})}}else if("reduce_stock"==b){a("table.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}});var g={};a(c).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");g[b.attr("data-order_item_id")]=c.val()});var f={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:d,order_item_qty:g,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(b){alert(b),a("table.woocommerce_order_items").unblock()}})}else if("increase_stock"==b){a("table.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}});var g={};a(c).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");g[b.attr("data-order_item_id")]=c.val()});var f={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:d,order_item_qty:g,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(b){alert(b),a("table.woocommerce_order_items").unblock()}})}return!1}),a(".wc-order-refund-items").on("change","#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","button.do-api-refund, button.do-manual-refund",function(){if(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}}),confirm(woocommerce_admin_meta_boxes.i18n_do_refund)){var b=a("input#refund_amount").val(),c=a("input#refund_reason").val(),d=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}),e={action:"woocommerce_refund_line_items",order_id:woocommerce_admin_meta_boxes.post_id,refund_amount:b,refund_reason:c,refund_qty:JSON.stringify(d,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,e,function(b){console.log(b),b===!0?window.location.reload():b.error&&(alert(b.error),a("#woocommerce-order-items").unblock())})}else a("#woocommerce-order-items").unblock()}),a("#woocommerce-order-totals").on("change input",".order_taxes_amount, .order_taxes_shipping_amount, .shipping_cost, #_order_discount",function(){var b=a(this),c=b.closest(".totals_group").find("input[type=number], .wc_input_price"),d=0;c.each(function(){a(this).val()&&(d+=accounting.unformat(a(this).val(),woocommerce_admin.mon_decimal_point))}),(b.is(".order_taxes_amount")||b.is(".order_taxes_shipping_amount"))&&(d=round(d,woocommerce_admin_meta_boxes.currency_format_num_decimals,woocommerce_admin_meta_boxes.tax_rounding_mode));var e=accounting.formatMoney(d,{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});b.closest(".totals_group").find("span.inline_total").text(e)}).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("#order_items_list").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}).on("click","button.calc_totals",function(){a("#woocommerce-order-totals").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_totals);if(b){var c=0,d=0,e=0,f=a("#_order_discount").val()||"0";f=accounting.unformat(f.replace(",",".")),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),e+=parseFloat(cost)}),a("#tax_rows").find("input[type=number], .wc_input_price").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),d+=parseFloat(cost)}),a("#order_items_list tr.item, #order_items_list 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()}return a("#woocommerce-order-totals").unblock(),!1}).on("click",".delete_refund",function(){if(confirm(woocommerce_admin_meta_boxes.i18n_delete_refund)){var b=a(this).closest("li"),c={action:"woocommerce_delete_refund",refund_id:b.data("id"),security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(){b.remove()})}return!1}),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){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_items_list tr.item, #order_items_list tr.fee").each(function(){a(this).trigger("init_row"),a(this).find(".edit").hide()}),a("#order_items_list").on("init_row","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","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(),!1}).on("click","a.delete_order_item",function(){var b=confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(b){var c=a(this).closest("tr.item, tr.fee"),d=c.attr("data-order_item_id");a("table.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}});var e={order_item_ids:d,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(){c.remove(),a("table.woocommerce_order_items").unblock()}})}return!1}).on("change","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","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","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","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","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",".wc-order-item-refund-quantity input",function(){var b=0,c=a("#order_items_list").find("tr.item, tr.fee");c.each(function(){var c=a(this),d=c.find(".wc-order-item-refund-quantity input").val();d&&(b=parseFloat(b)+d*(parseFloat(c.attr("data-unit_total"))+parseFloat(c.attr("data-unit_total_tax"))))}),a("#refund_amount").val(b).change()}).on("click","button.add_order_item_meta",function(){var b=a(this),c=b.closest("tr.item"),d={order_item_id:c.attr("data-order_item_id"),action:"woocommerce_add_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};return a("table.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}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){c.find("tbody.meta_items").append(b),a("table.woocommerce_order_items").unblock()}}),!1}).on("click","button.remove_order_item_meta",function(){var b=confirm(woocommerce_admin_meta_boxes.remove_item_meta);if(b){var c=a(this).closest("tr"),d={meta_id:c.attr("data-meta_id"),action:"woocommerce_remove_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};a("table.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}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(){c.hide(),a("table.woocommerce_order_items").unblock()}})}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(".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(".wc-order-item-refund-quantity").hide(),a(".wc-order-edit-line-item").show(),!1}).on("click","button.add_order_item",function(){void 0===window.WCBackbone.Modal.__instance&&(window.WCBackbone.Modal.__instance=new WCBackbone.Modal.View({target:"#wc-modal-add-products"}))}).on("click","button.add_order_fee",function(){a("table.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}});var b={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,b,function(b){a("table.woocommerce_order_items tbody#order_items_list").append(b),a("table.woocommerce_order_items").unblock()}),!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 b=a(this).closest(".bulk_actions").find("select").val(),c=a("#woocommerce-order-items").find(".check-column input:checked"),d=[];if(a(c).each(function(){var b=a(this).closest("tr.item, tr.fee");d.push(b.attr("data-order_item_id"))}),0==d.length)return void alert(woocommerce_admin_meta_boxes.i18n_select_items);if("delete"==b){var e=confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(e){a("table.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}});var f={order_item_ids:d,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){a(c).each(function(){a(this).closest("tr.item, tr.fee").remove()}),a("table.woocommerce_order_items").unblock()}})}}else if("reduce_stock"==b){a("table.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}});var g={};a(c).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");g[b.attr("data-order_item_id")]=c.val()});var f={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:d,order_item_qty:g,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(b){alert(b),a("table.woocommerce_order_items").unblock()}})}else if("increase_stock"==b){a("table.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}});var g={};a(c).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");g[b.attr("data-order_item_id")]=c.val()});var f={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:d,order_item_qty:g,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(b){alert(b),a("table.woocommerce_order_items").unblock()}})}return!1}),a(".wc-order-refund-items").on("change","#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","button.do-api-refund, button.do-manual-refund",function(){if(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}}),confirm(woocommerce_admin_meta_boxes.i18n_do_refund)){var b=a("input#refund_amount").val(),c=a("input#refund_reason").val(),d=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}),e={action:"woocommerce_refund_line_items",order_id:woocommerce_admin_meta_boxes.post_id,refund_amount:b,refund_reason:c,refund_qty:JSON.stringify(d,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,e,function(b){console.log(b),b===!0?window.location.reload():b.error&&(alert(b.error),a("#woocommerce-order-items").unblock())})}else a("#woocommerce-order-items").unblock()}),a("#woocommerce-order-totals").on("change input",".order_taxes_amount, .order_taxes_shipping_amount, .shipping_cost, #_order_discount",function(){var b=a(this),c=b.closest(".totals_group").find("input[type=number], .wc_input_price"),d=0;c.each(function(){a(this).val()&&(d+=accounting.unformat(a(this).val(),woocommerce_admin.mon_decimal_point))}),(b.is(".order_taxes_amount")||b.is(".order_taxes_shipping_amount"))&&(d=round(d,woocommerce_admin_meta_boxes.currency_format_num_decimals,woocommerce_admin_meta_boxes.tax_rounding_mode));var e=accounting.formatMoney(d,{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});b.closest(".totals_group").find("span.inline_total").text(e)}).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("#order_items_list").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}).on("click","button.calc_totals",function(){a("#woocommerce-order-totals").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_totals);if(b){var c=0,d=0,e=0,f=a("#_order_discount").val()||"0";f=accounting.unformat(f.replace(",",".")),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),e+=parseFloat(cost)}),a("#tax_rows").find("input[type=number], .wc_input_price").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),d+=parseFloat(cost)}),a("#order_items_list tr.item, #order_items_list 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()}return a("#woocommerce-order-totals").unblock(),!1}).on("click",".delete_refund",function(){if(confirm(woocommerce_admin_meta_boxes.i18n_delete_refund)){var b=a(this).closest("li"),c={action:"woocommerce_delete_refund",refund_id:b.data("id"),security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(){b.remove()})}return!1}),a("body").on("wc_backbone_modal_response",function(b,c){if("#wc-modal-add-products"===c){var d=a("select#add_item_id").val();d?(count=d.length,a("table.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}}),a.each(d,function(b,c){var d={action:"woocommerce_add_order_item",item_to_add:c,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_items_list").append(b),--count||(a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","").val(""),a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),a("select#add_item_id").trigger("chosen:updated"),a("table.woocommerce_order_items").unblock()),a("#order_items_list 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("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 diff --git a/assets/js/admin/meta-boxes.js b/assets/js/admin/meta-boxes.js index 4d8d6b9b8f8..8724d6d593f 100644 --- a/assets/js/admin/meta-boxes.js +++ b/assets/js/admin/meta-boxes.js @@ -1,5 +1,6 @@ -jQuery( function($){ - +/*global woocommerce_admin_meta_boxes */ +jQuery( function ( $ ) { + // run tip tip function runTipTip() { // remove any lingering tooltips @@ -19,11 +20,11 @@ jQuery( function($){ $('#titlediv #title').keyup(function( event ) { var code = event.keyCode || event.which; - if ( code == '9' && $('#woocommerce-coupon-description').size() > 0 ) { - event.stopPropagation(); - $('#woocommerce-coupon-description').focus(); - return false; - } + if ( code == '9' && $('#woocommerce-coupon-description').size() > 0 ) { + event.stopPropagation(); + $('#woocommerce-coupon-description').focus(); + return false; + } }); $(function(){ @@ -56,61 +57,79 @@ jQuery( function($){ // Ajax Chosen Product Selectors jQuery("select.ajax_chosen_select_products").ajaxChosen({ - method: 'GET', - url: woocommerce_admin_meta_boxes.ajax_url, - dataType: 'json', - afterTypeDelay: 100, - data: { - action: 'woocommerce_json_search_products', + method: 'GET', + url: woocommerce_admin_meta_boxes.ajax_url, + dataType: 'json', + afterTypeDelay: 100, + data: { + action: 'woocommerce_json_search_products', security: woocommerce_admin_meta_boxes.search_products_nonce - } + } }, function (data) { var terms = {}; - $.each(data, function (i, val) { - terms[i] = val; - }); + $.each(data, function (i, val) { + terms[i] = val; + }); - return terms; + return terms; }); - jQuery("select.ajax_chosen_select_products_and_variations").ajaxChosen({ - method: 'GET', - url: woocommerce_admin_meta_boxes.ajax_url, - dataType: 'json', - afterTypeDelay: 100, - data: { - action: 'woocommerce_json_search_products_and_variations', - security: woocommerce_admin_meta_boxes.search_products_nonce - } - }, function (data) { - var terms = {}; + /** + * Load Chosen for select products and variations + * + * @return {void} + */ + function loadSelectProductAndVariation() { + $( 'select.ajax_chosen_select_products_and_variations' ).ajaxChosen({ + method: 'GET', + url: woocommerce_admin_meta_boxes.ajax_url, + dataType: 'json', + afterTypeDelay: 100, + data: { + action: 'woocommerce_json_search_products_and_variations', + security: woocommerce_admin_meta_boxes.search_products_nonce + } + }, + function ( data ) { + var terms = {}; - $.each(data, function (i, val) { - terms[i] = val; - }); + $.each(data, function ( i, val ) { + terms[i] = val; + }); - return terms; + return terms; + }); + } + + // Run on document load + loadSelectProductAndVariation(); + + // Load chosen inside WC Backbone Modal + $( 'body' ).on( 'wc_backbone_modal_loaded', function ( e, target ) { + if ( '#wc-modal-add-products' === target ) { + loadSelectProductAndVariation(); + } }); jQuery("select.ajax_chosen_select_downloadable_products_and_variations").ajaxChosen({ - method: 'GET', - url: woocommerce_admin_meta_boxes.ajax_url, - dataType: 'json', - afterTypeDelay: 100, - data: { - action: 'woocommerce_json_search_downloadable_products_and_variations', + method: 'GET', + url: woocommerce_admin_meta_boxes.ajax_url, + dataType: 'json', + afterTypeDelay: 100, + data: { + action: 'woocommerce_json_search_downloadable_products_and_variations', security: woocommerce_admin_meta_boxes.search_products_nonce - } + } }, function (data) { var terms = {}; - $.each(data, function (i, val) { - terms[i] = val; - }); + $.each(data, function (i, val) { + terms[i] = val; + }); - return terms; + return terms; }); $( ".date-picker" ).datepicker({ @@ -147,4 +166,4 @@ jQuery( function($){ jQuery(this).find('.wc-metabox-content').hide(); }); -}); \ No newline at end of file +}); diff --git a/assets/js/admin/meta-boxes.min.js b/assets/js/admin/meta-boxes.min.js index bdbd2972303..3ec3b6c191b 100644 --- a/assets/js/admin/meta-boxes.min.js +++ b/assets/js/admin/meta-boxes.min.js @@ -1 +1 @@ -jQuery(function(a){function b(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}b(),a("#titlediv #title").keyup(function(b){var c=b.keyCode||b.which;return"9"==c&&a("#woocommerce-coupon-description").size()>0?(b.stopPropagation(),a("#woocommerce-coupon-description").focus(),!1):void 0}),a(function(){jQuery(".wc-metabox > h3").click(function(){a(this).parent(".wc-metabox").toggleClass("closed").toggleClass("open")})}),a("ul.wc-tabs").show(),a("div.panel-wrap").each(function(){a(this).find("div.panel:not(:first)").hide()}),a("ul.wc-tabs a").click(function(){var b=a(this).closest("div.panel-wrap");return a("ul.wc-tabs li",b).removeClass("active"),a(this).parent().addClass("active"),a("div.panel",b).hide(),a(a(this).attr("href")).show(),!1}),a("ul.wc-tabs li:visible").eq(0).find("a").click(),jQuery("select.chosen_select").chosen(),jQuery("select.chosen_select_nostd").chosen({allow_single_deselect:"true"}),jQuery("select.ajax_chosen_select_products").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c}),jQuery("select.ajax_chosen_select_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products_and_variations",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c}),jQuery("select.ajax_chosen_select_downloadable_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_downloadable_products_and_variations",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c}),a(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0}),a(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0}),jQuery(".wc-metaboxes-wrapper").on("click",".wc-metabox h3",function(b){a(b.target).filter(":input, option").length||jQuery(this).next(".wc-metabox-content").toggle()}).on("click",".expand_all",function(){return jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").show(),!1}).on("click",".close_all",function(){return jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").hide(),!1}),jQuery(".wc-metabox.closed").each(function(){jQuery(this).find(".wc-metabox-content").hide()})}); \ No newline at end of file +jQuery(function(a){function b(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}function c(){a("select.ajax_chosen_select_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products_and_variations",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c})}b(),a("#titlediv #title").keyup(function(b){var c=b.keyCode||b.which;return"9"==c&&a("#woocommerce-coupon-description").size()>0?(b.stopPropagation(),a("#woocommerce-coupon-description").focus(),!1):void 0}),a(function(){jQuery(".wc-metabox > h3").click(function(){a(this).parent(".wc-metabox").toggleClass("closed").toggleClass("open")})}),a("ul.wc-tabs").show(),a("div.panel-wrap").each(function(){a(this).find("div.panel:not(:first)").hide()}),a("ul.wc-tabs a").click(function(){var b=a(this).closest("div.panel-wrap");return a("ul.wc-tabs li",b).removeClass("active"),a(this).parent().addClass("active"),a("div.panel",b).hide(),a(a(this).attr("href")).show(),!1}),a("ul.wc-tabs li:visible").eq(0).find("a").click(),jQuery("select.chosen_select").chosen(),jQuery("select.chosen_select_nostd").chosen({allow_single_deselect:"true"}),jQuery("select.ajax_chosen_select_products").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c}),c(),a("body").on("wc_backbone_modal_loaded",function(a,b){"#wc-modal-add-products"===b&&c()}),jQuery("select.ajax_chosen_select_downloadable_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_downloadable_products_and_variations",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c}),a(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0}),a(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0}),jQuery(".wc-metaboxes-wrapper").on("click",".wc-metabox h3",function(b){a(b.target).filter(":input, option").length||jQuery(this).next(".wc-metabox-content").toggle()}).on("click",".expand_all",function(){return jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").show(),!1}).on("click",".close_all",function(){return jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").hide(),!1}),jQuery(".wc-metabox.closed").each(function(){jQuery(this).find(".wc-metabox-content").hide()})}); \ No newline at end of file diff --git a/assets/js/admin/order-backbone-modal.js b/assets/js/admin/order-backbone-modal.js index 03ac3ddd7d0..282fe50ab19 100644 --- a/assets/js/admin/order-backbone-modal.js +++ b/assets/js/admin/order-backbone-modal.js @@ -27,6 +27,7 @@ $( 'body' ).css({ 'overflow': 'hidden' }).append( this.$el ); + $( 'body' ).trigger( 'wc_backbone_modal_loaded', this._target ); }, closeButton: function ( e ) { e.preventDefault(); @@ -36,10 +37,11 @@ 'overflow': 'auto' }); this.remove(); + $( 'body' ).trigger( 'wc_backbone_modal_removed', this._target ); window.WCBackbone.Modal.__instance = undefined; }, addButton: function ( e ) { - $( 'body' ).trigger( 'wc_backbone_modal_response', this.getFormData() ); + $( 'body' ).trigger( 'wc_backbone_modal_response', this._target, this.getFormData() ); this.closeButton( e ); }, getFormData: function () { diff --git a/assets/js/admin/order-backbone-modal.min.js b/assets/js/admin/order-backbone-modal.min.js index 0a4dbc86e73..1251009a6dc 100644 --- a/assets/js/admin/order-backbone-modal.min.js +++ b/assets/js/admin/order-backbone-modal.min.js @@ -1 +1 @@ -!function(a,b,c){"use strict";window.WCBackbone={Modal:{__instance:void 0}},window.WCBackbone.Modal.View=b.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:void 0,events:{"click #btn-cancel":"closeButton","click #btn-ok":"addButton"},initialize:function(a){this._target=a.target,c.bindAll(this,"render"),this.render()},render:function(){this.$el.attr("tabindex","0").append(a(this._target).html()),a("body").css({overflow:"hidden"}).append(this.$el)},closeButton:function(b){b.preventDefault(),this.undelegateEvents(),a(document).off("focusin"),a("body").css({overflow:"auto"}),this.remove(),window.WCBackbone.Modal.__instance=void 0},addButton:function(b){a("body").trigger("wc_backbone_modal_response",this.getFormData()),this.closeButton(b)},getFormData:function(){var b={};return a.each(a("form",this.$el).serializeArray(),function(c,d){b.hasOwnProperty(d.name)?(b[d.name]=a.makeArray(b[d.name]),b[d.name].push(d.value)):b[d.name]=d.value}),b}})}(jQuery,Backbone,_); \ No newline at end of file +!function(a,b,c){"use strict";window.WCBackbone={Modal:{__instance:void 0}},window.WCBackbone.Modal.View=b.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:void 0,events:{"click #btn-cancel":"closeButton","click #btn-ok":"addButton"},initialize:function(a){this._target=a.target,c.bindAll(this,"render"),this.render()},render:function(){this.$el.attr("tabindex","0").append(a(this._target).html()),a("body").css({overflow:"hidden"}).append(this.$el),a("body").trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(b){b.preventDefault(),this.undelegateEvents(),a(document).off("focusin"),a("body").css({overflow:"auto"}),this.remove(),a("body").trigger("wc_backbone_modal_removed",this._target),window.WCBackbone.Modal.__instance=void 0},addButton:function(b){a("body").trigger("wc_backbone_modal_response",this._target,this.getFormData()),this.closeButton(b)},getFormData:function(){var b={};return a.each(a("form",this.$el).serializeArray(),function(c,d){b.hasOwnProperty(d.name)?(b[d.name]=a.makeArray(b[d.name]),b[d.name].push(d.value)):b[d.name]=d.value}),b}})}(jQuery,Backbone,_); \ No newline at end of file diff --git a/includes/admin/meta-boxes/class-wc-meta-box-order-items.php b/includes/admin/meta-boxes/class-wc-meta-box-order-items.php index 3c42ed6295d..6a3f2da9c60 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-order-items.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-order-items.php @@ -133,8 +133,7 @@ class WC_Meta_Box_Order_Items {

@@ -165,6 +164,30 @@ class WC_Meta_Box_Order_Items { + +