woocommerce/assets/js/admin/meta-boxes-order.js

1141 lines
35 KiB
JavaScript
Raw Normal View History

/*global woocommerce_admin_meta_boxes, woocommerce_admin, accounting */
jQuery( function ( $ ) {
2013-11-12 17:01:13 +00:00
/**
* Add order items loading block
*/
function addOrderItemsLoading() {
2014-07-16 20:12:33 +00:00
$( '#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
}
});
}
/**
* Remove order items loading block
*/
function removeOrderItemsLoading() {
2014-07-16 20:12:33 +00:00
$( '#woocommerce-order-items' ).unblock();
}
2014-07-18 23:27:10 +00:00
/**
* Run TipTip
*/
function runTipTip() {
$( '#tiptip_holder' ).removeAttr( 'style' );
$( '#tiptip_arrow' ).removeAttr( 'style' );
$( '.tips' ).tipTip({
'attribute': 'data-tip',
'fadeIn': 50,
'fadeOut': 50,
'delay': 200
});
}
/**
* Load order items
*
* @return {void}
*/
function loadOrderItems() {
var data = {
order_id: woocommerce_admin_meta_boxes.post_id,
action: 'woocommerce_load_order_items',
security: woocommerce_admin_meta_boxes.order_item_nonce
};
addOrderItemsLoading();
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function( response ) {
$( '#woocommerce-order-items .inside' ).empty();
$( '#woocommerce-order-items .inside' ).append( response );
2014-07-18 23:27:10 +00:00
runTipTip();
removeOrderItemsLoading();
}
});
}
2011-08-09 15:16:18 +00:00
// ORDERS
$( '#woocommerce-order-actions input, #woocommerce-order-actions a' ).click( function () {
window.onbeforeunload = '';
});
2012-08-01 12:43:46 +00:00
$( '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();
2011-11-25 19:31:06 +00:00
});
2012-11-27 16:22:47 +00:00
$( 'body' )
.on( 'click', 'a.edit-order-item', function() {
$( this ).closest( 'tr' ).find( '.view' ).hide();
$( this ).closest( 'tr' ).find( '.edit' ).show();
$( this ).hide();
$( 'button.add-line-item' ).click();
$( 'button.cancel-action' ).attr( 'data-reload', true );
2014-07-10 10:25:50 +00:00
return false;
})
2014-07-22 13:18:11 +00:00
.on( 'click', '.woocommerce_order_items a.delete-order-item', function () {
var answer = window.confirm( woocommerce_admin_meta_boxes.remove_item_notice );
2014-07-10 10:25:50 +00:00
if ( answer ) {
var $item = $( this ).closest( 'tr.item, tr.fee, tr.shipping' );
2014-07-10 10:25:50 +00:00
var order_item_id = $item.attr( 'data-order_item_id' );
addOrderItemsLoading();
2014-07-10 10:25:50 +00:00
var data = {
order_item_ids: order_item_id,
action: 'woocommerce_remove_order_item',
security: woocommerce_admin_meta_boxes.order_item_nonce
2014-07-10 10:25:50 +00:00
};
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function ( response ) {
2014-07-10 10:25:50 +00:00
$item.remove();
removeOrderItemsLoading();
2014-07-10 10:25:50 +00:00
}
});
2014-07-10 10:25:50 +00:00
}
return false;
})
2014-07-22 13:18:11 +00:00
.on( 'click', '#order_refunds .delete_refund', function () {
2014-07-16 20:12:33 +00:00
if ( window.confirm( woocommerce_admin_meta_boxes.i18n_delete_refund ) ) {
var $refund = $( this ).closest( 'tr.refund' );
var refund_id = $refund.attr( 'data-order_refund_id' );
addOrderItemsLoading();
var data = {
action: 'woocommerce_delete_refund',
refund_id: refund_id,
security: woocommerce_admin_meta_boxes.order_item_nonce,
};
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function ( response ) {
loadOrderItems();
2014-07-16 20:12:33 +00:00
}
});
}
return false;
})
2014-07-10 10:25:50 +00:00
// When the qty is changed, increase or decrease costs
2014-07-22 19:52:36 +00:00
.on( 'change', '.woocommerce_order_items input.quantity', function () {
var $row = $( this ).closest( 'tr.item' );
var qty = $( this ).val();
var o_qty = $( this ).attr( 'data-qty' );
var line_total = $( 'input.line_total', $row );
var line_subtotal = $( 'input.line_subtotal', $row );
// Totals
var unit_total = accounting.unformat( line_total.attr( 'data-total' ), woocommerce_admin.mon_decimal_point );
line_total.val(
parseFloat( accounting.formatNumber( unit_total * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) )
.toString()
.replace( '.', woocommerce_admin.mon_decimal_point )
);
var unit_subtotal = accounting.unformat( line_subtotal.attr( 'data-subtotal' ), woocommerce_admin.mon_decimal_point );
line_subtotal.val(
parseFloat( accounting.formatNumber( unit_subtotal * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) )
.toString()
.replace( '.', woocommerce_admin.mon_decimal_point )
);
// Taxes
$( 'td.line_tax', $row ).each( function() {
var line_total_tax = $( 'input.line_tax', $( this ) );
var unit_total_tax = accounting.unformat( line_total_tax.attr( 'data-total_tax' ), woocommerce_admin.mon_decimal_point );
if ( 0 < unit_total_tax ) {
line_total_tax.val(
parseFloat( accounting.formatNumber( unit_total_tax * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) )
.toString()
.replace( '.', woocommerce_admin.mon_decimal_point )
);
}
var line_subtotal_tax = $( 'input.line_subtotal_tax', $( this ) );
var unit_subtotal_tax = accounting.unformat( line_subtotal_tax.attr( 'data-subtotal_tax' ), woocommerce_admin.mon_decimal_point );
if ( 0 < unit_subtotal_tax ) {
line_subtotal_tax.val(
parseFloat( accounting.formatNumber( unit_subtotal_tax * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) )
.toString()
.replace( '.', woocommerce_admin.mon_decimal_point )
);
}
});
2014-07-10 10:25:50 +00:00
2014-07-22 19:52:36 +00:00
$( this ).trigger( 'quantity_changed' );
2014-07-10 10:25:50 +00:00
})
// When the refund qty is changed, increase or decrease costs
.on( 'change', '.woocommerce_order_items input.refund_order_item_qty', function () {
var $row = $( this ).closest( 'tr.item' );
var qty = $( this ).val();
var o_qty = $row.find('input.quantity').attr( 'data-qty' );
var line_total = $( 'input.line_total', $row );
var refund_line_total = $( 'input.refund_line_total', $row );
// Totals
var unit_total = accounting.unformat( line_total.attr( 'data-total' ), woocommerce_admin.mon_decimal_point );
refund_line_total.val(
parseFloat( accounting.formatNumber( unit_total * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) )
.toString()
.replace( '.', woocommerce_admin.mon_decimal_point )
);
// Taxes
$( 'td.line_tax', $row ).each( function() {
var line_total_tax = $( 'input.line_tax', $( this ) );
var refund_line_total_tax = $( 'input.refund_line_tax', $( this ) );
var unit_total_tax = accounting.unformat( line_total_tax.attr( 'data-total_tax' ), woocommerce_admin.mon_decimal_point );
if ( 0 < unit_total_tax ) {
refund_line_total_tax.val(
parseFloat( accounting.formatNumber( unit_total_tax * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) )
.toString()
.replace( '.', woocommerce_admin.mon_decimal_point )
);
}
});
$( this ).trigger( 'refund_quantity_changed' );
})
.on( 'change', '.woocommerce_order_items .refund input', function () {
2014-07-10 10:25:50 +00:00
var refund_amount = 0;
2014-07-22 13:18:11 +00:00
var $items = $( '.woocommerce_order_items' ).find( 'tr.item, tr.fee, tr.shipping' );
2014-07-10 10:25:50 +00:00
2014-07-21 02:26:40 +00:00
$items.each( function () {
var $row = $( this );
var refund_cost_fields = $row.find( '.refund input:not(.refund_order_item_qty)' );
2014-07-10 10:25:50 +00:00
refund_cost_fields.each(function( index, el ){
refund_amount += parseFloat( accounting.unformat( $( el ).val() || 0, woocommerce_admin.mon_decimal_point ) );
});
2014-07-21 02:26:40 +00:00
});
$( '#refund_amount' )
.val( accounting.formatNumber(
refund_amount,
woocommerce_admin_meta_boxes.currency_format_num_decimals,
'',
woocommerce_admin.mon_decimal_point
) )
.change();
2014-07-10 10:25:50 +00:00
})
// Add some meta to a line item
2014-07-22 13:18:11 +00:00
.on( 'click', '.woocommerce_order_items button.add_order_item_meta', function () {
2014-07-10 10:25:50 +00:00
var $button = $( this );
var $item = $button.closest( 'tr.item' );
var data = {
2014-07-22 19:52:36 +00:00
order_item_id: $item.attr( 'data-order_item_id' ),
action: 'woocommerce_add_order_item_meta',
security: woocommerce_admin_meta_boxes.order_item_nonce
};
addOrderItemsLoading();
2014-07-10 10:25:50 +00:00
$.ajax( {
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function( response ) {
2014-07-10 10:25:50 +00:00
$item.find('tbody.meta_items').append( response );
removeOrderItemsLoading();
}
} );
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
return false;
})
// Remove some meta from a line item
2014-07-22 19:52:36 +00:00
.on( 'click', '.woocommerce_order_items button.remove_order_item_meta', function () {
if ( window.confirm( woocommerce_admin_meta_boxes.remove_item_meta ) ) {
var $row = $( this ).closest( 'tr' );
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
var data = {
2014-07-22 19:52:36 +00:00
meta_id: $row.attr( 'data-meta_id' ),
action: 'woocommerce_remove_order_item_meta',
security: woocommerce_admin_meta_boxes.order_item_nonce
2014-07-10 10:25:50 +00:00
};
2012-11-27 16:22:47 +00:00
addOrderItemsLoading();
2014-07-10 10:25:50 +00:00
$.ajax( {
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function( response ) {
$row.hide();
removeOrderItemsLoading();
2014-07-10 10:25:50 +00:00
}
} );
}
2014-07-10 10:25:50 +00:00
return false;
2014-07-22 15:44:02 +00:00
})
// Subtotal/total inputs
2014-07-22 19:52:36 +00:00
.on( 'keyup', '.woocommerce_order_items .split-input input:eq(0)', function () {
var $subtotal = $( this ).next();
if ( $subtotal.val() === '' || $subtotal.is( '.match-total' ) ) {
$subtotal.val( $( this ).val() ).addClass( 'match-total' );
2014-07-22 15:44:02 +00:00
}
})
2014-07-22 19:52:36 +00:00
.on( 'keyup', '.woocommerce_order_items .split-input input:eq(0)', function () {
$( this ).removeClass( 'match-total' );
});
2014-07-10 10:25:50 +00:00
$( '#woocommerce-order-items' )
.on( 'click', 'button.add-line-item', function () {
$( 'div.wc-order-add-item' ).slideDown();
$( 'div.wc-order-bulk-actions' ).slideUp();
2014-07-10 10:25:50 +00:00
return false;
})
.on( 'click', 'button.refund-items', function () {
$( 'div.wc-order-refund-items' ).slideDown();
$( 'div.wc-order-bulk-actions' ).slideUp();
$( 'div.wc-order-totals-items' ).slideUp();
2014-07-24 09:56:32 +00:00
$( '#woocommerce-order-items .refund' ).show();
$( '.wc-order-edit-line-item' ).hide();
2014-07-10 10:25:50 +00:00
return false;
})
.on( 'click', '.cancel-action', function () {
$( this ).closest( 'div.wc-order-data-row' ).slideUp();
$( 'div.wc-order-bulk-actions' ).slideDown();
$( 'div.wc-order-totals-items' ).slideDown();
2014-07-24 09:56:32 +00:00
$( '#woocommerce-order-items .refund' ).hide();
$( '.wc-order-edit-line-item' ).show();
// Reload the items
if ( 'true' === $( this ).attr( 'data-reload' ) ) {
loadOrderItems();
}
2014-07-10 10:25:50 +00:00
return false;
})
2014-07-21 02:58:34 +00:00
.on( 'click', 'button.add-order-item', function () {
$( this ).WCBackboneModal({
template: '#wc-modal-add-products'
});
return false;
})
.on( 'click', 'button.add-order-fee', function () {
addOrderItemsLoading();
var data = {
action: 'woocommerce_add_order_fee',
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 ) {
2014-07-22 13:18:11 +00:00
$( 'table.woocommerce_order_items tbody#order_fee_line_items' ).append( response );
removeOrderItemsLoading();
});
2014-07-21 02:58:34 +00:00
return false;
2014-07-10 10:25:50 +00:00
})
.on( 'click', 'button.add-order-shipping', function () {
addOrderItemsLoading();
2012-11-12 18:53:40 +00:00
var data = {
action: 'woocommerce_add_order_shipping',
order_id: woocommerce_admin_meta_boxes.post_id,
security: woocommerce_admin_meta_boxes.order_item_nonce
2012-11-12 18:53:40 +00:00
};
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
2014-07-22 13:18:11 +00:00
$( 'table.woocommerce_order_items tbody#order_shipping_line_items' ).append( response );
removeOrderItemsLoading();
2012-01-13 21:25:39 +00:00
});
2014-07-21 02:58:34 +00:00
return false;
})
.on( 'click', 'button.add-order-tax', function () {
$( this ).WCBackboneModal({
template: '#wc-modal-add-tax'
});
2014-07-10 10:25:50 +00:00
return false;
})
// Bulk actions for line items
.on( 'click', 'input.check-column', function() {
2014-07-22 19:52:36 +00:00
if ( $( this ).is( ':checked' ) ) {
$( '#woocommerce-order-items' ).find( '.check-column input' ).attr( 'checked', 'checked' );
} else {
2014-07-22 19:52:36 +00:00
$( '#woocommerce-order-items' ).find( '.check-column input' ).removeAttr( 'checked' );
}
2014-07-10 10:25:50 +00:00
})
2014-07-22 19:52:36 +00:00
.on( 'click', '.do_bulk_action', function () {
var action = $( this ).closest( '.bulk-actions' ).find( 'select' ).val();
var selected_rows = $( '#woocommerce-order-items' ).find( '.check-column input:checked' );
var item_ids = [];
2012-01-13 21:25:39 +00:00
2014-07-22 19:52:36 +00:00
$( selected_rows ).each( function () {
var $item = $( this ).closest( 'tr' );
if ( $item.attr( 'data-order_item_id' ) ) {
item_ids.push( $item.attr( 'data-order_item_id' ) );
}
2014-07-10 10:25:50 +00:00
} );
2012-11-27 16:22:47 +00:00
2014-07-22 19:52:36 +00:00
if ( item_ids.length === 0 ) {
window.alert( woocommerce_admin_meta_boxes.i18n_select_items );
2014-07-10 10:25:50 +00:00
return;
}
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
if ( action === 'delete' ) {
if ( window.confirm( woocommerce_admin_meta_boxes.remove_item_notice ) ) {
2012-08-01 12:43:46 +00:00
addOrderItemsLoading();
2011-08-09 15:16:18 +00:00
2014-07-10 10:25:50 +00:00
var data = {
2014-07-22 19:52:36 +00:00
order_item_ids: item_ids,
action: 'woocommerce_remove_order_item',
security: woocommerce_admin_meta_boxes.order_item_nonce
2014-07-10 10:25:50 +00:00
};
2012-11-27 16:22:47 +00:00
2014-07-22 19:52:36 +00:00
$.ajax({
2014-07-10 10:25:50 +00:00
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
2014-07-22 19:52:36 +00:00
success: function ( response ) {
$( selected_rows ).each( function () {
$( this ).closest( 'tr' ).remove();
});
removeOrderItemsLoading();
2014-07-10 10:25:50 +00:00
}
2014-07-22 19:52:36 +00:00
});
2014-07-10 10:25:50 +00:00
}
2014-07-22 19:52:36 +00:00
} else if ( action === 'reduce_stock' ) {
2012-11-27 16:22:47 +00:00
addOrderItemsLoading();
2012-08-01 12:43:46 +00:00
2014-07-10 10:25:50 +00:00
var quantities = {};
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( selected_rows ).each( function () {
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
var $item = $( this ).closest( 'tr.item, tr.fee' );
var $qty = $item.find( 'input.quantity' );
2012-08-01 12:43:46 +00:00
2014-07-10 10:25:50 +00:00
quantities[ $item.attr( 'data-order_item_id' ) ] = $qty.val();
} );
2012-08-01 12:43:46 +00:00
var data = {
2014-07-22 19:52:36 +00:00
order_id: woocommerce_admin_meta_boxes.post_id,
order_item_ids: item_ids,
order_item_qty: quantities,
action: 'woocommerce_reduce_order_item_stock',
security: woocommerce_admin_meta_boxes.order_item_nonce
};
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$.ajax({
2014-07-10 10:25:50 +00:00
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
2014-07-22 19:52:36 +00:00
success: function ( response ) {
window.alert( response );
removeOrderItemsLoading();
2014-07-10 10:25:50 +00:00
}
} );
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
} else if ( action === 'increase_stock' ) {
addOrderItemsLoading();
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
var quantities = {};
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( selected_rows ).each( function () {
2011-08-09 15:16:18 +00:00
2014-07-22 19:52:36 +00:00
var $item = $( this ).closest( 'tr.item, tr.fee' );
var $qty = $item.find( 'input.quantity' );
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
quantities[ $item.attr( 'data-order_item_id' ) ] = $qty.val();
} );
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
var data = {
2014-07-22 19:52:36 +00:00
order_id: woocommerce_admin_meta_boxes.post_id,
order_item_ids: item_ids,
order_item_qty: quantities,
action: 'woocommerce_increase_order_item_stock',
security: woocommerce_admin_meta_boxes.order_item_nonce
2014-07-10 10:25:50 +00:00
};
2012-11-12 13:41:54 +00:00
2014-07-22 19:52:36 +00:00
$.ajax({
2014-07-10 10:25:50 +00:00
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
2014-07-22 19:52:36 +00:00
success: function ( response ) {
window.alert( response );
removeOrderItemsLoading();
2014-07-10 10:25:50 +00:00
}
2014-07-22 19:52:36 +00:00
});
2014-07-10 10:25:50 +00:00
}
2012-11-12 13:41:54 +00:00
return false;
})
.on( 'click', 'button.calculate-action', function () {
if ( window.confirm( woocommerce_admin_meta_boxes.calc_totals ) ) {
addOrderItemsLoading();
// Get row totals
var line_totals = 0;
var tax = 0;
var shipping = 0;
var order_discount = $( '#_order_discount' ).val() || '0';
order_discount = accounting.unformat( order_discount.replace( ',', '.' ) );
2014-07-22 13:18:11 +00:00
$( '.woocommerce_order_items tr.shipping input.line_total' ).each( function () {
var cost = $( this ).val() || '0';
cost = accounting.unformat( cost, woocommerce_admin.mon_decimal_point );
shipping = shipping + parseFloat( cost );
});
2014-07-22 13:18:11 +00:00
$( '.woocommerce_order_items input.line_tax' ).each( function () {
var cost = $( this ).val() || '0';
cost = accounting.unformat( cost, woocommerce_admin.mon_decimal_point );
tax = tax + parseFloat( cost );
});
2014-07-22 13:18:11 +00:00
$( '.woocommerce_order_items tr.item, .woocommerce_order_items tr.fee' ).each( function () {
var line_total = $( this ).find( 'input.line_total' ).val() || '0';
line_totals = line_totals + accounting.unformat( line_total.replace( ',', '.' ) );
});
// Tax
if ( 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal ) {
tax = parseFloat( accounting.toFixed( tax, woocommerce_admin_meta_boxes.rounding_precision ) );
}
// Set Total
$( '#_order_total' )
.val( accounting.formatNumber( line_totals + tax + shipping - order_discount, woocommerce_admin_meta_boxes.currency_format_num_decimals, '', woocommerce_admin.mon_decimal_point ) )
.change();
$( 'button.save-action' ).click();
}
return false;
})
.on( 'click', 'button.save-action', function () {
var data = {
order_id: woocommerce_admin_meta_boxes.post_id,
items: $( '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
};
addOrderItemsLoading();
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function( response ) {
$( '#woocommerce-order-items .inside' ).empty();
$( '#woocommerce-order-items .inside' ).append( response );
2014-07-18 23:27:10 +00:00
runTipTip();
removeOrderItemsLoading();
}
});
2014-07-21 01:57:23 +00:00
return false;
})
.on( 'click', 'a.delete-order-tax', function () {
if ( window.confirm( woocommerce_admin_meta_boxes.i18n_delete_tax ) ) {
addOrderItemsLoading();
2014-07-21 01:57:23 +00:00
var data = {
action: 'woocommerce_remote_order_tax',
rate_id: $( this ).attr( 'data-rate_id' ),
order_id: woocommerce_admin_meta_boxes.post_id,
security: woocommerce_admin_meta_boxes.order_item_nonce
};
2014-07-22 15:44:02 +00:00
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function( response ) {
$( '#woocommerce-order-items .inside' ).empty();
$( '#woocommerce-order-items .inside' ).append( response );
runTipTip();
removeOrderItemsLoading();
}
});
}
2014-07-10 10:25:50 +00:00
return false;
2012-11-12 13:41:54 +00:00
});
// Refund actions
$( 'body' )
.on( 'change', '.wc-order-refund-items #refund_amount', function () {
var total = accounting.unformat( $( this ).val(), woocommerce_admin.mon_decimal_point );
$( 'button .wc-order-refund-amount .amount' ).text( accounting.formatMoney( total, {
2014-07-16 20:12:33 +00:00
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
2014-07-10 10:25:50 +00:00
} ) );
})
.on( 'click', '.wc-order-refund-items button.do-api-refund, .wc-order-refund-items button.do-manual-refund', function () {
2014-07-16 20:12:33 +00:00
addOrderItemsLoading();
if ( window.confirm( woocommerce_admin_meta_boxes.i18n_do_refund ) ) {
var refund_amount = $( 'input#refund_amount' ).val();
var refund_reason = $( 'input#refund_reason' ).val();
2014-07-24 14:34:14 +00:00
// Get line item refunds
var line_item_qtys = {};
var line_item_totals = {};
var line_item_tax_totals = {};
$( '.refund input.refund_order_item_qty' ).each( function( index, item ) {
if ( $( item ).closest( 'tr' ).data( 'order_item_id' ) ) {
if ( item.value ) {
line_item_qtys[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = item.value;
}
}
});
$( '.refund input.refund_line_total' ).each( function( index, item ) {
if ( $( item ).closest( 'tr' ).data( 'order_item_id' ) ) {
line_item_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = accounting.unformat( item.value, woocommerce_admin.mon_decimal_point );
}
});
$( '.refund input.refund_line_tax' ).each( function( index, item ) {
if ( $( item ).closest( 'tr' ).data( 'order_item_id' ) ) {
2014-07-24 14:34:14 +00:00
var tax_id = $( item ).data( 'tax_id' );
if ( ! line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] ) {
line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = {};
}
line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ][ tax_id ] = accounting.unformat( item.value, woocommerce_admin.mon_decimal_point );
}
2014-07-10 12:33:05 +00:00
});
2014-07-24 14:34:14 +00:00
var data = {
action: 'woocommerce_refund_line_items',
order_id: woocommerce_admin_meta_boxes.post_id,
refund_amount: refund_amount,
refund_reason: refund_reason,
line_item_qtys: JSON.stringify( line_item_qtys, null, '' ),
line_item_totals: JSON.stringify( line_item_totals, null, '' ),
line_item_tax_totals: JSON.stringify( line_item_tax_totals, null, '' ),
api_refund: $( this ).is( '.do-api-refund' ),
security: woocommerce_admin_meta_boxes.order_item_nonce
2014-07-10 12:33:05 +00:00
};
2014-07-24 14:34:14 +00:00
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
2014-07-10 13:49:04 +00:00
if ( response === true ) {
loadOrderItems();
2014-07-10 13:49:04 +00:00
} else if ( response.error ) {
window.alert( response.error );
2014-07-16 20:12:33 +00:00
removeOrderItemsLoading();
} else {
console.log(response);
2014-07-10 12:33:05 +00:00
}
});
} else {
2014-07-16 20:12:33 +00:00
removeOrderItemsLoading();
2014-07-10 12:33:05 +00:00
}
2014-07-10 10:25:50 +00:00
});
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
// Display a total for taxes
$('#woocommerce-order-totals')
// Calculate totals
.on('click', 'button.calc_line_taxes', function(){
// Block write panel
$('.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: 0.6 } });
var answer = confirm(woocommerce_admin_meta_boxes.calc_line_taxes);
if (answer) {
2014-07-22 13:18:11 +00:00
var $items = $('.woocommerce_order_items').find('tr.item, tr.fee');
2014-07-10 10:25:50 +00:00
var shipping_country = $('#_shipping_country').val();
var billing_country = $('#_billing_country').val();
if (shipping_country) {
var country = shipping_country;
var state = $('#_shipping_state').val();
var postcode = $('#_shipping_postcode').val();
var city = $('#_shipping_city').val();
} else if(billing_country) {
var country = billing_country;
var state = $('#_billing_state').val();
var postcode = $('#_billing_postcode').val();
var city = $('#_billing_city').val();
} else {
var country = woocommerce_admin_meta_boxes.base_country;
var state = '';
var postcode = '';
var city = '';
}
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
// Get items and values
var calculate_items = {};
2012-11-12 12:22:35 +00:00
2014-07-10 10:25:50 +00:00
$items.each( function() {
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
var $row = $(this);
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
var item_id = $row.find('input.order_item_id').val();
var line_subtotal = $row.find('input.line_subtotal').val();
var line_total = $row.find('input.line_total').val();
var tax_class = $row.find('select.tax_class').val();
2014-07-10 10:25:50 +00:00
calculate_items[ item_id ] = {};
calculate_items[ item_id ].line_subtotal = line_subtotal;
calculate_items[ item_id ].line_total = line_total;
calculate_items[ item_id ].tax_class = tax_class;
} );
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
order_shipping = 0;
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
$('#shipping_rows').find('input[type=number], .wc_input_price').each(function(){
cost = $(this).val() || '0';
cost = accounting.unformat( cost, woocommerce_admin.mon_decimal_point );
order_shipping = order_shipping + parseFloat( cost );
});
2012-11-27 16:22:47 +00:00
2012-11-12 12:22:35 +00:00
var data = {
2014-07-10 10:25:50 +00:00
action: 'woocommerce_calc_line_taxes',
order_id: woocommerce_admin_meta_boxes.post_id,
items: calculate_items,
shipping: order_shipping,
country: country,
state: state,
postcode: postcode,
city: city,
security: woocommerce_admin_meta_boxes.calc_totals_nonce
2012-11-12 12:22:35 +00:00
};
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
if ( response ) {
$items.each( function() {
var $row = $(this);
var item_id = $row.find('input.order_item_id').val();
$row.find('.edit-order-item').click();
2014-07-10 10:25:50 +00:00
if ( response['item_taxes'][ item_id ] ) {
$row.find('input.line_tax').val( response['item_taxes'][ item_id ]['line_tax'] ).change();
$row.find('input.line_subtotal_tax').val( response['item_taxes'][ item_id ]['line_subtotal_tax'] ).change();
}
if ( response['tax_row_html'] )
$('#tax_rows').empty().append( response['tax_row_html'] );
2012-11-12 14:34:10 +00:00
} );
2014-07-10 10:25:50 +00:00
$('#tax_rows').find('input').change();
2012-11-12 12:22:35 +00:00
}
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
$('.woocommerce_order_items_wrapper').unblock();
});
} else {
$('.woocommerce_order_items_wrapper').unblock();
2012-11-10 16:18:20 +00:00
}
2014-07-10 10:25:50 +00:00
return false;
});
2012-11-27 16:22:47 +00:00
// 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 ) {
var count = add_item_ids.length;
addOrderItemsLoading();
2014-07-21 01:36:12 +00:00
$.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
};
2014-07-21 01:36:12 +00:00
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
2014-07-22 13:18:11 +00:00
$( 'table.woocommerce_order_items tbody#order_line_items' ).append( response );
if ( !--count ) {
$( 'select#add_item_id, #add_item_id_chosen .chosen-choices' ).css( 'border-color', '' ).val( '' );
2014-07-18 23:27:10 +00:00
runTipTip();
$( 'select#add_item_id' ).trigger( 'chosen:updated' );
removeOrderItemsLoading();
}
});
});
} else {
$( 'select#add_item_id, #add_item_id_chosen .chosen-choices' ).css( 'border-color', 'red' );
}
});
2014-07-21 01:36:12 +00:00
// Adds new tax in order items
$( 'body' ).on( 'wc_backbone_modal_response', function ( e, target ) {
if ( '#wc-modal-add-tax' !== target ) {
return;
}
var manual_rate_id = $( '#manual_tax_rate_id' ).val();
var rate_id = $( 'input[name=add_order_tax]:checked' ).val();
if ( manual_rate_id ) {
rate_id = manual_rate_id;
}
if ( ! rate_id ) {
return false;
}
var rates = $( '.order-tax-id' ).map( function () {
return $( this ).val();
}).get();
2014-07-21 01:36:12 +00:00
// Test if already exists
if ( -1 === $.inArray( rate_id, rates ) ) {
addOrderItemsLoading();
2014-07-21 01:36:12 +00:00
var data = {
action: 'woocommerce_add_order_tax',
rate_id: rate_id,
order_id: woocommerce_admin_meta_boxes.post_id,
security: woocommerce_admin_meta_boxes.order_item_nonce
};
2014-07-21 01:36:12 +00:00
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function( response ) {
$( '#woocommerce-order-items .inside' ).empty();
$( '#woocommerce-order-items .inside' ).append( response );
runTipTip();
removeOrderItemsLoading();
}
});
} else {
window.alert( woocommerce_admin_meta_boxes.i18n_tax_rate_already_exists );
}
2014-07-21 01:36:12 +00:00
});
2014-07-22 19:52:36 +00:00
$( 'span.inline_total' ).closest( '.totals_group' ).find( 'input' ).change();
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
// Download permissions
2014-07-22 19:52:36 +00:00
$( '.order_download_permissions' )
.on( 'click', 'button.grant_access', function () {
var products = $( 'select#grant_access_id' ).val();
2012-11-27 16:22:47 +00:00
2014-07-22 19:52:36 +00:00
if ( ! products ) {
return;
}
$( '.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: 0.6
}
});
2012-11-27 16:22:47 +00:00
2012-11-12 12:22:35 +00:00
var data = {
2014-07-22 19:52:36 +00:00
action: 'woocommerce_grant_access_to_download',
product_ids: products,
loop: $('.order_download_permissions .wc-metabox').size(),
order_id: woocommerce_admin_meta_boxes.post_id,
security: woocommerce_admin_meta_boxes.grant_access_nonce,
2012-11-12 12:22:35 +00:00
};
2012-11-27 16:22:47 +00:00
2014-07-10 10:25:50 +00:00
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
2014-07-10 10:25:50 +00:00
if ( response ) {
2014-07-22 19:52:36 +00:00
$( '.order_download_permissions .wc-metaboxes' ).append( response );
2014-07-10 10:25:50 +00:00
} else {
2014-07-22 19:52:36 +00:00
window.alert( woocommerce_admin_meta_boxes.i18n_download_permission_fail );
2014-07-10 10:25:50 +00:00
}
2014-07-22 19:52:36 +00:00
$( '.date-picker' ).datepicker({
dateFormat: 'yy-mm-dd',
numberOfMonths: 1,
2014-07-10 10:25:50 +00:00
showButtonPanel: true,
2014-07-22 19:52:36 +00:00
showOn: 'button',
buttonImage: woocommerce_admin_meta_boxes.calendar_image,
2014-07-10 10:25:50 +00:00
buttonImageOnly: true
});
2014-07-22 19:52:36 +00:00
$( '#grant_access_id' ).val( '' ).trigger( 'chosen:updated' );
$( '.order_download_permissions' ).unblock();
});
2014-07-10 10:25:50 +00:00
return false;
})
2014-07-22 19:52:36 +00:00
.on( 'click', 'button.revoke_access', function () {
if ( window.confirm( woocommerce_admin_meta_boxes.i18n_permission_revoke ) ) {
var el = $( this ).parent().parent();
var product = $( this ).attr( 'rel' ).split( ',' )[0];
var file = $( this ).attr( 'rel' ).split( ',' )[1];
2014-07-10 10:25:50 +00:00
if ( product > 0 ) {
2014-07-22 19:52:36 +00:00
$( el ).block({
message: null,
overlayCSS: {
background: '#fff url(' + woocommerce_admin_meta_boxes.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center',
opacity: 0.6
}
});
2014-07-10 10:25:50 +00:00
var data = {
2014-07-22 19:52:36 +00:00
action: 'woocommerce_revoke_access_to_download',
product_id: product,
download_id: file,
order_id: woocommerce_admin_meta_boxes.post_id,
security: woocommerce_admin_meta_boxes.revoke_access_nonce,
2014-07-10 10:25:50 +00:00
};
2014-07-22 19:52:36 +00:00
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
2014-07-10 10:25:50 +00:00
// Success
2014-07-22 19:52:36 +00:00
$( el ).fadeOut( '300', function () {
$( el ).remove();
2014-07-10 10:25:50 +00:00
});
});
2014-07-10 10:25:50 +00:00
} else {
2014-07-22 19:52:36 +00:00
$( el ).fadeOut( '300', function () {
$( el ).remove();
});
2014-07-10 10:25:50 +00:00
}
}
2014-07-10 10:25:50 +00:00
return false;
});
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( 'button.load_customer_billing' ).on( 'click', function () {
if ( window.confirm( woocommerce_admin_meta_boxes.load_billing ) ) {
2012-08-01 12:43:46 +00:00
2011-11-26 16:15:25 +00:00
// Get user ID to load data for
2014-07-22 19:52:36 +00:00
var user_id = $( '#customer_user' ).val();
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
if ( ! user_id ) {
window.alert( woocommerce_admin_meta_boxes.no_customer_selected );
2011-11-26 16:15:25 +00:00
return false;
}
2012-08-01 12:43:46 +00:00
2011-11-26 16:15:25 +00:00
var data = {
2014-07-22 19:52:36 +00:00
user_id: user_id,
type_to_load: 'billing',
action: 'woocommerce_get_customer_details',
security: woocommerce_admin_meta_boxes.get_customer_details_nonce
2011-11-26 16:15:25 +00:00
};
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( 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: 0.6
}
});
2012-08-01 12:43:46 +00:00
2011-11-26 16:15:25 +00:00
$.ajax({
2013-08-06 10:41:20 +00:00
url: woocommerce_admin_meta_boxes.ajax_url,
2011-11-26 16:15:25 +00:00
data: data,
type: 'POST',
2014-07-22 19:52:36 +00:00
success: function ( response ) {
2013-01-22 14:35:10 +00:00
var info = response;
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
if ( info ) {
$( 'input#_billing_first_name' ).val( info.billing_first_name );
$( 'input#_billing_last_name' ).val( info.billing_last_name );
$( 'input#_billing_company' ).val( info.billing_company );
$( 'input#_billing_address_1' ).val( info.billing_address_1 );
$( 'input#_billing_address_2' ).val( info.billing_address_2 );
$( 'input#_billing_city' ).val( info.billing_city );
$( 'input#_billing_postcode' ).val( info.billing_postcode );
$( '#_billing_country' ).val( info.billing_country );
$( 'input#_billing_state' ).val( info.billing_state );
$( 'input#_billing_email' ).val( info.billing_email );
$( 'input#_billing_phone' ).val( info.billing_phone );
2011-11-26 16:15:25 +00:00
}
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( '.edit_address' ).unblock();
2011-11-26 16:15:25 +00:00
}
});
}
return false;
});
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( 'button.load_customer_shipping' ).on( 'click', function () {
if ( window.confirm( woocommerce_admin_meta_boxes.load_shipping ) ) {
2012-08-01 12:43:46 +00:00
2011-11-26 16:15:25 +00:00
// Get user ID to load data for
2014-07-22 19:52:36 +00:00
var user_id = $( '#customer_user' ).val();
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
if ( ! user_id ) {
window.alert( woocommerce_admin_meta_boxes.no_customer_selected );
2011-11-26 16:15:25 +00:00
return false;
}
2012-08-01 12:43:46 +00:00
2011-11-26 16:15:25 +00:00
var data = {
2014-07-22 19:52:36 +00:00
user_id: user_id,
type_to_load: 'shipping',
action: 'woocommerce_get_customer_details',
security: woocommerce_admin_meta_boxes.get_customer_details_nonce
2011-11-26 16:15:25 +00:00
};
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( 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: 0.6
}
});
2012-08-01 12:43:46 +00:00
2011-11-26 16:15:25 +00:00
$.ajax({
2013-08-06 10:41:20 +00:00
url: woocommerce_admin_meta_boxes.ajax_url,
2011-11-26 16:15:25 +00:00
data: data,
type: 'POST',
2014-07-22 19:52:36 +00:00
success: function ( response ) {
2013-01-22 14:35:10 +00:00
var info = response;
2013-01-22 16:48:28 +00:00
2014-07-22 19:52:36 +00:00
if ( info ) {
$( 'input#_shipping_first_name' ).val( info.shipping_first_name );
$( 'input#_shipping_last_name' ).val( info.shipping_last_name );
$( 'input#_shipping_company' ).val( info.shipping_company );
$( 'input#_shipping_address_1' ).val( info.shipping_address_1 );
$( 'input#_shipping_address_2' ).val( info.shipping_address_2 );
$( 'input#_shipping_city' ).val( info.shipping_city );
$( 'input#_shipping_postcode' ).val( info.shipping_postcode );
$( '#_shipping_country' ).val( info.shipping_country );
$( 'input#_shipping_state' ).val( info.shipping_state );
2011-11-26 16:15:25 +00:00
}
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( '.edit_address' ).unblock();
2011-11-26 16:15:25 +00:00
}
});
}
return false;
});
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( 'button.billing-same-as-shipping' ).on( 'click', function () {
if ( window.confirm( woocommerce_admin_meta_boxes.copy_billing ) ) {
$( 'input#_shipping_first_name' ).val( $( 'input#_billing_first_name' ).val() );
$( 'input#_shipping_last_name' ).val( $( 'input#_billing_last_name' ).val() );
$( 'input#_shipping_company' ).val( $( 'input#_billing_company' ).val() );
$( 'input#_shipping_address_1' ).val( $( 'input#_billing_address_1' ).val() );
$( 'input#_shipping_address_2' ).val( $( 'input#_billing_address_2' ).val() );
$( 'input#_shipping_city' ).val( $( 'input#_billing_city' ).val() );
$( 'input#_shipping_postcode' ).val( $( 'input#_billing_postcode' ).val() );
$( '#_shipping_country' ).val( $( '#_billing_country' ).val() );
$( 'input#_shipping_state' ).val( $( 'input#_billing_state' ).val() );
2011-08-09 15:16:18 +00:00
}
return false;
});
2012-08-01 12:43:46 +00:00
2014-07-22 19:52:36 +00:00
$( '.totals_group' ).on( 'click', 'a.add_total_row', function () {
$( this ).closest( '.totals_group' ).find( '.total_rows' ).append( $( this ).data( 'row' ) );
return false;
});
2012-11-27 16:22:47 +00:00
2014-07-22 19:52:36 +00:00
$( '.total_rows' ).on( 'click', 'a.delete_total_row', function () {
var $row = $( this ).closest( '.total_row' );
var row_id = $row.attr( 'data-order_item_id' );
2012-11-27 16:22:47 +00:00
if ( row_id ) {
2014-07-22 19:52:36 +00:00
$row.append( '<input type="hidden" name="delete_order_item_id[]" value="' + row_id + '" />' ).hide();
} else {
$row.remove();
}
2012-11-27 16:22:47 +00:00
2011-12-31 19:03:41 +00:00
return false;
});
2012-08-01 12:43:46 +00:00
2013-11-28 12:03:29 +00:00
// Order notes
2014-07-22 19:52:36 +00:00
$( '#woocommerce-order-notes' )
.on( 'click', 'a.add_note', function () {
if ( ! $( 'textarea#add_order_note' ).val() ) {
return;
}
$( '#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: 0.6
}
});
2013-11-28 12:03:29 +00:00
2014-07-10 10:25:50 +00:00
var data = {
2014-07-22 19:52:36 +00:00
action: 'woocommerce_add_order_note',
post_id: woocommerce_admin_meta_boxes.post_id,
note: $( 'textarea#add_order_note' ).val(),
note_type: $( 'select#order_note_type' ).val(),
security: woocommerce_admin_meta_boxes.add_order_note_nonce,
2014-07-10 10:25:50 +00:00
};
2013-11-28 12:03:29 +00:00
2014-07-22 19:52:36 +00:00
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
$( 'ul.order_notes' ).prepend( response );
$( '#woocommerce-order-notes' ).unblock();
$( '#add_order_note' ).val( '' );
2014-07-10 10:25:50 +00:00
});
2013-11-28 12:03:29 +00:00
2014-07-10 10:25:50 +00:00
return false;
2013-11-28 12:03:29 +00:00
2014-07-10 10:25:50 +00:00
})
2014-07-22 19:52:36 +00:00
.on( 'click', 'a.delete_note', function () {
var note = $( this ).closest( 'li.note' );
$( note ).block({
message: null,
overlayCSS: {
background: '#fff url(' + woocommerce_admin_meta_boxes.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center',
opacity: 0.6
}
});
2013-11-28 12:03:29 +00:00
2014-07-10 10:25:50 +00:00
var data = {
2014-07-22 19:52:36 +00:00
action: 'woocommerce_delete_order_note',
note_id: $( note ).attr( 'rel' ),
security: woocommerce_admin_meta_boxes.delete_order_note_nonce,
2014-07-10 10:25:50 +00:00
};
2013-11-28 12:03:29 +00:00
2014-07-22 19:52:36 +00:00
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
$( note ).remove();
2014-07-10 10:25:50 +00:00
});
return false;
});
});