created method for delete order tax

This commit is contained in:
claudiosmweb 2014-07-20 22:57:23 -03:00
parent d875cfa1ac
commit 144d094ad2
6 changed files with 64 additions and 26 deletions

File diff suppressed because one or more lines are too long

View File

@ -848,6 +848,21 @@ ul.wc_coupon_list_block {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat center;
}
}
.delete-order-tax {
.ir;
display: inline-block;
margin: 0;
&:before {
.icon;
content: "\e013";
color: #999;
}
&:hover {
&:before {
color: @red;
}
}
}
}
}

View File

@ -555,6 +555,31 @@ jQuery( function ( $ ) {
}
});
return false;
})
.on( 'click', 'a.delete-order-tax', function () {
addOrderItemsLoading();
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
};
$.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();
}
});
return false;
});
@ -612,30 +637,6 @@ jQuery( function ( $ ) {
// Display a total for taxes
$('#woocommerce-order-totals')
.on( 'change input', '.order_taxes_amount, .order_taxes_shipping_amount, .shipping_cost, #_order_discount', function() {
var $this = $(this);
var fields = $this.closest('.totals_group').find('input[type=number], .wc_input_price');
var total = 0;
fields.each(function(){
if ( $(this).val() )
total = total + accounting.unformat( $(this).val(), woocommerce_admin.mon_decimal_point );
});
if ( $this.is('.order_taxes_amount') || $this.is('.order_taxes_shipping_amount') ) {
total = round( total, woocommerce_admin_meta_boxes.currency_format_num_decimals, woocommerce_admin_meta_boxes.tax_rounding_mode );
}
var formatted_total = accounting.formatMoney( total, {
symbol : woocommerce_admin_meta_boxes.currency_format_symbol,
decimal : woocommerce_admin_meta_boxes.currency_format_decimal_sep,
thousand : woocommerce_admin_meta_boxes.currency_format_thousand_sep,
precision : woocommerce_admin_meta_boxes.currency_format_num_decimals,
format : woocommerce_admin_meta_boxes.currency_format
} );
$this.closest('.totals_group').find('span.inline_total').text( formatted_total );
})
// Calculate totals
.on('click', 'button.calc_line_taxes', function(){
// Block write panel

File diff suppressed because one or more lines are too long

View File

@ -43,6 +43,7 @@ if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) {
echo esc_attr( $tax_item['label'] . ' (' . $tax_item['name'] . ')' );
?>">[?]</span>
<input type="hidden" name="order_taxes[<?php echo $tax_id; ?>]" value="<?php echo esc_attr( $tax_item['rate_id'] ); ?>">
<a class="delete-order-tax" href="#" data-rate_id="<?php echo $tax_id; ?>"></a>
</th>
<?php

View File

@ -47,6 +47,7 @@ class WC_AJAX {
'add_order_shipping' => false,
'add_order_tax' => false,
'remove_order_item' => false,
'remote_order_tax' => false,
'reduce_order_item_stock' => false,
'increase_order_item_stock' => false,
'add_order_item_meta' => false,
@ -1127,6 +1128,26 @@ class WC_AJAX {
die();
}
/**
* Remove an order tax
*/
public static function remote_order_tax() {
check_ajax_referer( 'order-item', 'security' );
$order_id = absint( $_POST['order_id'] );
$rate_id = absint( $_POST['rate_id'] );
wc_delete_order_item( $rate_id );
// Return HTML items
$order = new WC_Order( $order_id );
$data = get_post_meta( $order_id );
include( 'admin/meta-boxes/views/html-order-items.php' );
die();
}
/**
* Reduce order item stock
*/