fixed some js coding standards
This commit is contained in:
parent
b56b60f191
commit
fdf48d92e8
|
@ -81,9 +81,9 @@ jQuery( function ( $ ) {
|
|||
});
|
||||
|
||||
$( 'body' )
|
||||
.on( 'init_row', '#order_line_items tr.item', function() {
|
||||
.on( 'init_row', '#order_line_items tr.item', function () {
|
||||
var $row = $(this);
|
||||
var $qty = $row.find('input.quantity');
|
||||
var $qty = $row.find( 'input.quantity' );
|
||||
var qty = $qty.val();
|
||||
|
||||
var line_subtotal = accounting.unformat( $row.find('input.line_subtotal').val(), woocommerce_admin.mon_decimal_point );
|
||||
|
@ -92,10 +92,10 @@ jQuery( function ( $ ) {
|
|||
var line_subtotal_tax = accounting.unformat( $row.find('input.line_subtotal_tax').val(), woocommerce_admin.mon_decimal_point );
|
||||
|
||||
if ( qty ) {
|
||||
unit_subtotal = parseFloat( accounting.toFixed( ( line_subtotal / qty ), woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_subtotal_tax = parseFloat( accounting.toFixed( ( line_subtotal_tax / qty ), woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_total = parseFloat( accounting.toFixed( ( line_total / qty ), woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_total_tax = parseFloat( accounting.toFixed( ( line_tax / qty ), woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_subtotal = parseFloat( accounting.toFixed( ( line_subtotal / qty ), woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_subtotal_tax = parseFloat( accounting.toFixed( ( line_subtotal_tax / qty ), woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_total = parseFloat( accounting.toFixed( ( line_total / qty ), woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_total_tax = parseFloat( accounting.toFixed( ( line_tax / qty ), woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
} else {
|
||||
unit_subtotal = unit_subtotal_tax = unit_total = unit_total_tax = 0;
|
||||
}
|
||||
|
@ -106,14 +106,14 @@ jQuery( function ( $ ) {
|
|||
$row.attr( 'data-unit_total', unit_total );
|
||||
$row.attr( 'data-unit_total_tax', unit_total_tax );
|
||||
})
|
||||
.on( 'init_row', '#order_fee_line_items tr.fee', function() {
|
||||
.on( 'init_row', '#order_fee_line_items tr.fee', function () {
|
||||
var $row = $(this);
|
||||
|
||||
var line_total = accounting.unformat( $row.find('input.line_total').val(), woocommerce_admin.mon_decimal_point );
|
||||
var line_tax = accounting.unformat( $row.find('input.line_tax').val(), woocommerce_admin.mon_decimal_point );
|
||||
var line_total = accounting.unformat( $row.find('input.line_total').val(), woocommerce_admin.mon_decimal_point );
|
||||
var line_tax = accounting.unformat( $row.find('input.line_tax').val(), woocommerce_admin.mon_decimal_point );
|
||||
|
||||
unit_total = parseFloat( accounting.toFixed( line_total, woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_total_tax = parseFloat( accounting.toFixed( line_tax, woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_total = parseFloat( accounting.toFixed( line_total, woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
unit_total_tax = parseFloat( accounting.toFixed( line_tax, woocommerce_admin_meta_boxes.rounding_precision ) );
|
||||
|
||||
$row.attr( 'data-unit_total', unit_total );
|
||||
$row.attr( 'data-unit_total_tax', unit_total_tax );
|
||||
|
@ -179,15 +179,15 @@ jQuery( function ( $ ) {
|
|||
return false;
|
||||
})
|
||||
// When the qty is changed, increase or decrease costs
|
||||
.on( 'change', '.woocommerce_order_items input.quantity', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var qty = $(this).val();
|
||||
.on( 'change', '.woocommerce_order_items input.quantity', function () {
|
||||
var $row = $( this ).closest( 'tr.item' );
|
||||
var qty = $( this ).val();
|
||||
|
||||
var unit_subtotal = $row.attr('data-unit_subtotal');
|
||||
var unit_subtotal_tax = $row.attr('data-unit_subtotal_tax');
|
||||
var unit_total = $row.attr('data-unit_total');
|
||||
var unit_total_tax = $row.attr('data-unit_total_tax');
|
||||
var o_qty = $(this).attr('data-o_qty');
|
||||
var unit_subtotal = $row.attr( 'data-unit_subtotal' );
|
||||
var unit_subtotal_tax = $row.attr( 'data-unit_subtotal_tax' );
|
||||
var unit_total = $row.attr( 'data-unit_total' );
|
||||
var unit_total_tax = $row.attr( 'data-unit_total_tax' );
|
||||
var o_qty = $( this ).attr( 'data-o_qty' );
|
||||
|
||||
var subtotal = parseFloat( accounting.formatNumber( unit_subtotal * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) );
|
||||
var tax = parseFloat( accounting.formatNumber( unit_subtotal_tax * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) );
|
||||
|
@ -199,46 +199,46 @@ jQuery( function ( $ ) {
|
|||
total = total.toString().replace( '.', woocommerce_admin.mon_decimal_point );
|
||||
total_tax = total_tax.toString().replace( '.', woocommerce_admin.mon_decimal_point );
|
||||
|
||||
$row.find('input.line_subtotal').val( subtotal );
|
||||
$row.find('input.line_total').val( total );
|
||||
$row.find('input.line_subtotal_tax').val( tax );
|
||||
$row.find('input.line_tax').val( total_tax );
|
||||
$row.find( 'input.line_subtotal' ).val( subtotal );
|
||||
$row.find( 'input.line_total' ).val( total );
|
||||
$row.find( 'input.line_subtotal_tax' ).val( tax );
|
||||
$row.find( 'input.line_tax' ).val( total_tax );
|
||||
|
||||
$(this).trigger('quantity_changed');
|
||||
$( this ).trigger( 'quantity_changed' );
|
||||
})
|
||||
// When subtotal is changed, update the unit costs
|
||||
.on( 'change', '.woocommerce_order_items input.line_subtotal', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var $qty = $row.find('input.quantity');
|
||||
.on( 'change', '.woocommerce_order_items input.line_subtotal', function () {
|
||||
var $row = $( this ).closest( 'tr.item' );
|
||||
var $qty = $row.find( 'input.quantity' );
|
||||
var qty = $qty.val();
|
||||
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), woocommerce_admin_meta_boxes.rounding_precision ) : 0;
|
||||
var value = ( qty ) ? accounting.toFixed( ( $( this ).val() / qty ), woocommerce_admin_meta_boxes.rounding_precision ) : 0;
|
||||
|
||||
$row.attr( 'data-unit_subtotal', value );
|
||||
})
|
||||
// When total is changed, update the unit costs + discount amount
|
||||
.on( 'change', '.woocommerce_order_items input.line_total', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var $qty = $row.find('input.quantity');
|
||||
.on( 'change', '.woocommerce_order_items input.line_total', function () {
|
||||
var $row = $( this ).closest( 'tr.item' );
|
||||
var $qty = $row.find( 'input.quantity' );
|
||||
var qty = $qty.val();
|
||||
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), woocommerce_admin_meta_boxes.rounding_precision ) : 0;
|
||||
var value = ( qty ) ? accounting.toFixed( ( $( this ).val() / qty ), woocommerce_admin_meta_boxes.rounding_precision ) : 0;
|
||||
|
||||
$row.attr( 'data-unit_total', value );
|
||||
})
|
||||
// When total is changed, update the unit costs + discount amount
|
||||
.on( 'change', '.woocommerce_order_items input.line_subtotal_tax', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var $qty = $row.find('input.quantity');
|
||||
.on( 'change', '.woocommerce_order_items input.line_subtotal_tax', function () {
|
||||
var $row = $( this ).closest( 'tr.item' );
|
||||
var $qty = $row.find( 'input.quantity' );
|
||||
var qty = $qty.val();
|
||||
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), woocommerce_admin_meta_boxes.rounding_precision ) : 0;
|
||||
var value = ( qty ) ? accounting.toFixed( ( $( this ).val() / qty ), woocommerce_admin_meta_boxes.rounding_precision ) : 0;
|
||||
|
||||
$row.attr( 'data-unit_subtotal_tax', value );
|
||||
})
|
||||
// When total is changed, update the unit costs + discount amount
|
||||
.on( 'change', '.woocommerce_order_items input.line_tax', function() {
|
||||
var $row = $(this).closest('tr.item');
|
||||
var $qty = $row.find('input.quantity');
|
||||
.on( 'change', '.woocommerce_order_items input.line_tax', function () {
|
||||
var $row = $( this ).closest( 'tr.item' );
|
||||
var $qty = $row.find( 'input.quantity' );
|
||||
var qty = $qty.val();
|
||||
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), woocommerce_admin_meta_boxes.rounding_precision ) : 0;
|
||||
var value = ( qty ) ? accounting.toFixed( ( $( this ).val() / qty ), woocommerce_admin_meta_boxes.rounding_precision ) : 0;
|
||||
|
||||
$row.attr( 'data-unit_total_tax', value );
|
||||
})
|
||||
|
@ -280,9 +280,9 @@ jQuery( function ( $ ) {
|
|||
var $item = $button.closest( 'tr.item' );
|
||||
|
||||
var data = {
|
||||
order_item_id: $item.attr( 'data-order_item_id' ),
|
||||
action: 'woocommerce_add_order_item_meta',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
order_item_id: $item.attr( 'data-order_item_id' ),
|
||||
action: 'woocommerce_add_order_item_meta',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
|
||||
addOrderItemsLoading();
|
||||
|
@ -300,15 +300,14 @@ jQuery( function ( $ ) {
|
|||
return false;
|
||||
})
|
||||
// Remove some meta from a line item
|
||||
.on('click', '.woocommerce_order_items button.remove_order_item_meta', function(){
|
||||
var answer = confirm( woocommerce_admin_meta_boxes.remove_item_meta )
|
||||
if ( answer ) {
|
||||
var $row = $(this).closest('tr');
|
||||
.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' );
|
||||
|
||||
var data = {
|
||||
meta_id: $row.attr( 'data-meta_id' ),
|
||||
action: 'woocommerce_remove_order_item_meta',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
meta_id: $row.attr( 'data-meta_id' ),
|
||||
action: 'woocommerce_remove_order_item_meta',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
|
||||
addOrderItemsLoading();
|
||||
|
@ -326,14 +325,14 @@ jQuery( function ( $ ) {
|
|||
return false;
|
||||
})
|
||||
// Subtotal/total inputs
|
||||
.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');
|
||||
.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' );
|
||||
}
|
||||
})
|
||||
.on( 'keyup', '.woocommerce_order_items .split-input input:eq(0)', function(){
|
||||
$(this).removeClass('match-total');
|
||||
.on( 'keyup', '.woocommerce_order_items .split-input input:eq(0)', function () {
|
||||
$( this ).removeClass( 'match-total' );
|
||||
});
|
||||
|
||||
$( '#woocommerce-order-items' )
|
||||
|
@ -413,120 +412,117 @@ jQuery( function ( $ ) {
|
|||
})
|
||||
// Bulk actions for line items
|
||||
.on( 'click', 'input.check-column', function() {
|
||||
if ( $(this).is(':checked') ) {
|
||||
$('#woocommerce-order-items').find('.check-column input').attr('checked', 'checked');
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
$( '#woocommerce-order-items' ).find( '.check-column input' ).attr( 'checked', 'checked' );
|
||||
} else {
|
||||
$('#woocommerce-order-items').find('.check-column input').removeAttr('checked');
|
||||
$( '#woocommerce-order-items' ).find( '.check-column input' ).removeAttr( 'checked' );
|
||||
}
|
||||
})
|
||||
.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 = [];
|
||||
.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 = [];
|
||||
|
||||
$(selected_rows).each( function() {
|
||||
var $item = $(this).closest('tr');
|
||||
$( 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' ) );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( item_ids.length == 0 ) {
|
||||
alert( woocommerce_admin_meta_boxes.i18n_select_items );
|
||||
if ( item_ids.length === 0 ) {
|
||||
window.alert( woocommerce_admin_meta_boxes.i18n_select_items );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( action == 'delete' ) {
|
||||
|
||||
var answer = confirm( woocommerce_admin_meta_boxes.remove_item_notice );
|
||||
|
||||
if ( answer ) {
|
||||
if ( action === 'delete' ) {
|
||||
if ( window.confirm( woocommerce_admin_meta_boxes.remove_item_notice ) ) {
|
||||
|
||||
addOrderItemsLoading();
|
||||
|
||||
var data = {
|
||||
order_item_ids: item_ids,
|
||||
action: 'woocommerce_remove_order_item',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
order_item_ids: item_ids,
|
||||
action: 'woocommerce_remove_order_item',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
$(selected_rows).each( function() {
|
||||
$(this).closest('tr').remove();
|
||||
} );
|
||||
success: function ( response ) {
|
||||
$( selected_rows ).each( function () {
|
||||
$( this ).closest( 'tr' ).remove();
|
||||
});
|
||||
removeOrderItemsLoading();
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
} else if ( action == 'reduce_stock' ) {
|
||||
} else if ( action === 'reduce_stock' ) {
|
||||
|
||||
addOrderItemsLoading();
|
||||
|
||||
var quantities = {};
|
||||
|
||||
$(selected_rows).each( function() {
|
||||
$( selected_rows ).each( function () {
|
||||
|
||||
var $item = $(this).closest('tr.item, tr.fee');
|
||||
var $qty = $item.find('input.quantity');
|
||||
var $item = $( this ).closest( 'tr.item, tr.fee' );
|
||||
var $qty = $item.find( 'input.quantity' );
|
||||
|
||||
quantities[ $item.attr( 'data-order_item_id' ) ] = $qty.val();
|
||||
} );
|
||||
|
||||
var data = {
|
||||
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
|
||||
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
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
alert( response );
|
||||
removeOrderItemsLoading();
|
||||
}
|
||||
} );
|
||||
|
||||
} else if ( action == 'increase_stock' ) {
|
||||
} else if ( action === 'increase_stock' ) {
|
||||
|
||||
addOrderItemsLoading();
|
||||
|
||||
var quantities = {};
|
||||
|
||||
$(selected_rows).each( function() {
|
||||
$( selected_rows ).each( function () {
|
||||
|
||||
var $item = $(this).closest('tr.item, tr.fee');
|
||||
var $qty = $item.find('input.quantity');
|
||||
var $item = $( this ).closest( 'tr.item, tr.fee' );
|
||||
var $qty = $item.find( 'input.quantity' );
|
||||
|
||||
quantities[ $item.attr( 'data-order_item_id' ) ] = $qty.val();
|
||||
} );
|
||||
|
||||
var data = {
|
||||
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
|
||||
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
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
alert( response );
|
||||
success: function ( response ) {
|
||||
window.alert( response );
|
||||
removeOrderItemsLoading();
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -853,207 +849,229 @@ jQuery( function ( $ ) {
|
|||
}
|
||||
});
|
||||
|
||||
$('span.inline_total').closest('.totals_group').find('input').change();
|
||||
$( 'span.inline_total' ).closest( '.totals_group' ).find( 'input' ).change();
|
||||
|
||||
// Download permissions
|
||||
$('.order_download_permissions')
|
||||
.on('click', 'button.grant_access', function(){
|
||||
var products = $('select#grant_access_id').val();
|
||||
if (!products) return;
|
||||
$( '.order_download_permissions' )
|
||||
.on( 'click', 'button.grant_access', function () {
|
||||
var products = $( 'select#grant_access_id' ).val();
|
||||
|
||||
$('.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 } });
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
var data = {
|
||||
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,
|
||||
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,
|
||||
};
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
|
||||
|
||||
if ( response ) {
|
||||
$('.order_download_permissions .wc-metaboxes').append( response );
|
||||
$( '.order_download_permissions .wc-metaboxes' ).append( response );
|
||||
} else {
|
||||
alert( woocommerce_admin_meta_boxes.i18n_download_permission_fail );
|
||||
window.alert( woocommerce_admin_meta_boxes.i18n_download_permission_fail );
|
||||
}
|
||||
|
||||
$( ".date-picker" ).datepicker({
|
||||
dateFormat: "yy-mm-dd",
|
||||
numberOfMonths: 1,
|
||||
$( '.date-picker' ).datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
numberOfMonths: 1,
|
||||
showButtonPanel: true,
|
||||
showOn: "button",
|
||||
buttonImage: woocommerce_admin_meta_boxes.calendar_image,
|
||||
showOn: 'button',
|
||||
buttonImage: woocommerce_admin_meta_boxes.calendar_image,
|
||||
buttonImageOnly: true
|
||||
});
|
||||
$('#grant_access_id').val('').trigger('chosen:updated');
|
||||
$('.order_download_permissions').unblock();
|
||||
|
||||
$( '#grant_access_id' ).val( '' ).trigger( 'chosen:updated' );
|
||||
$( '.order_download_permissions' ).unblock();
|
||||
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
.on('click', 'button.revoke_access', function(e){
|
||||
e.preventDefault();
|
||||
var answer = confirm( woocommerce_admin_meta_boxes.i18n_permission_revoke );
|
||||
if ( answer ) {
|
||||
var el = $(this).parent().parent();
|
||||
var product = $(this).attr('rel').split(",")[0];
|
||||
var file = $(this).attr('rel').split(",")[1];
|
||||
.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];
|
||||
|
||||
if ( product > 0 ) {
|
||||
$(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 } });
|
||||
$( 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
|
||||
}
|
||||
});
|
||||
|
||||
var data = {
|
||||
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,
|
||||
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,
|
||||
};
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function(response) {
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
|
||||
// Success
|
||||
$(el).fadeOut('300', function(){
|
||||
$(el).remove();
|
||||
$( el ).fadeOut( '300', function () {
|
||||
$( el ).remove();
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
$(el).fadeOut('300', function(){
|
||||
$(el).remove();
|
||||
$( el ).fadeOut( '300', function () {
|
||||
$( el ).remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('button.load_customer_billing').click(function(){
|
||||
var answer = confirm(woocommerce_admin_meta_boxes.load_billing);
|
||||
if (answer){
|
||||
$( 'button.load_customer_billing' ).on( 'click', function () {
|
||||
if ( window.confirm( woocommerce_admin_meta_boxes.load_billing ) ) {
|
||||
|
||||
// Get user ID to load data for
|
||||
var user_id = $('#customer_user').val();
|
||||
var user_id = $( '#customer_user' ).val();
|
||||
|
||||
if (!user_id) {
|
||||
alert(woocommerce_admin_meta_boxes.no_customer_selected);
|
||||
if ( ! user_id ) {
|
||||
window.alert( woocommerce_admin_meta_boxes.no_customer_selected );
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
user_id: user_id,
|
||||
type_to_load: 'billing',
|
||||
action: 'woocommerce_get_customer_details',
|
||||
security: woocommerce_admin_meta_boxes.get_customer_details_nonce
|
||||
user_id: user_id,
|
||||
type_to_load: 'billing',
|
||||
action: 'woocommerce_get_customer_details',
|
||||
security: woocommerce_admin_meta_boxes.get_customer_details_nonce
|
||||
};
|
||||
|
||||
$(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 } });
|
||||
$( 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
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
var info = response;
|
||||
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
|
||||
$('.edit_address').unblock();
|
||||
$( '.edit_address' ).unblock();
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('button.load_customer_shipping').click(function(){
|
||||
|
||||
var answer = confirm(woocommerce_admin_meta_boxes.load_shipping);
|
||||
if (answer){
|
||||
$( 'button.load_customer_shipping' ).on( 'click', function () {
|
||||
if ( window.confirm( woocommerce_admin_meta_boxes.load_shipping ) ) {
|
||||
|
||||
// Get user ID to load data for
|
||||
var user_id = $('#customer_user').val();
|
||||
var user_id = $( '#customer_user' ).val();
|
||||
|
||||
if (!user_id) {
|
||||
alert(woocommerce_admin_meta_boxes.no_customer_selected);
|
||||
if ( ! user_id ) {
|
||||
window.alert( woocommerce_admin_meta_boxes.no_customer_selected );
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
user_id: user_id,
|
||||
type_to_load: 'shipping',
|
||||
action: 'woocommerce_get_customer_details',
|
||||
security: woocommerce_admin_meta_boxes.get_customer_details_nonce
|
||||
user_id: user_id,
|
||||
type_to_load: 'shipping',
|
||||
action: 'woocommerce_get_customer_details',
|
||||
security: woocommerce_admin_meta_boxes.get_customer_details_nonce
|
||||
};
|
||||
|
||||
$(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 } });
|
||||
$( 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
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
var info = response;
|
||||
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
|
||||
$('.edit_address').unblock();
|
||||
$( '.edit_address' ).unblock();
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('button.billing-same-as-shipping').click(function(){
|
||||
var answer = confirm(woocommerce_admin_meta_boxes.copy_billing);
|
||||
if (answer){
|
||||
$('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() );
|
||||
$( '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() );
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.totals_group').on('click','a.add_total_row',function(){
|
||||
$(this).closest('.totals_group').find('.total_rows').append( $(this).data( 'row' ) );
|
||||
$( '.totals_group' ).on( 'click', 'a.add_total_row', function () {
|
||||
$( this ).closest( '.totals_group' ).find( '.total_rows' ).append( $( this ).data( 'row' ) );
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.total_rows').on('click','a.delete_total_row',function(){
|
||||
$row = $(this).closest('.total_row');
|
||||
$( '.total_rows' ).on( 'click', 'a.delete_total_row', function () {
|
||||
$row = $( this ).closest( '.total_row' );
|
||||
|
||||
var row_id = $row.attr( 'data-order_item_id' );
|
||||
|
||||
if ( row_id ) {
|
||||
$row.append('<input type="hidden" name="delete_order_item_id[]" value="' + row_id + '" />').hide();
|
||||
$row.append( '<input type="hidden" name="delete_order_item_id[]" value="' + row_id + '" />' ).hide();
|
||||
} else {
|
||||
$row.remove();
|
||||
}
|
||||
|
@ -1062,40 +1080,56 @@ jQuery( function ( $ ) {
|
|||
});
|
||||
|
||||
// Order notes
|
||||
$('#woocommerce-order-notes')
|
||||
.on( 'click', 'a.add_note', function() {
|
||||
if ( ! $('textarea#add_order_note').val() ) return;
|
||||
$( '#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
|
||||
}
|
||||
});
|
||||
|
||||
$('#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 } });
|
||||
var data = {
|
||||
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,
|
||||
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,
|
||||
};
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function(response) {
|
||||
$('ul.order_notes').prepend( response );
|
||||
$('#woocommerce-order-notes').unblock();
|
||||
$('#add_order_note').val('');
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
|
||||
$( 'ul.order_notes' ).prepend( response );
|
||||
$( '#woocommerce-order-notes' ).unblock();
|
||||
$( '#add_order_note' ).val( '' );
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
})
|
||||
.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 } });
|
||||
.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
|
||||
}
|
||||
});
|
||||
|
||||
var data = {
|
||||
action: 'woocommerce_delete_order_note',
|
||||
note_id: $(note).attr('rel'),
|
||||
security: woocommerce_admin_meta_boxes.delete_order_note_nonce,
|
||||
action: 'woocommerce_delete_order_note',
|
||||
note_id: $( note ).attr( 'rel' ),
|
||||
security: woocommerce_admin_meta_boxes.delete_order_note_nonce,
|
||||
};
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function(response) {
|
||||
$(note).remove();
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function ( response ) {
|
||||
$( note ).remove();
|
||||
});
|
||||
|
||||
return false;
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue