save/update shipping taxes

This commit is contained in:
claudiosmweb 2014-07-20 00:56:38 -03:00
parent 3a28c56876
commit 2cfebdc6c5
2 changed files with 6 additions and 2 deletions

View File

@ -70,7 +70,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php echo ( '' != $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ) ) : ''; ?>
</div>
<div class="edit" style="display: none;">
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo absint( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="line_tax wc_input_price" />
<input type="text" name="shipping_taxes[<?php echo absint( $item_id ); ?>][<?php echo absint( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="shipping_taxes wc_input_price" />
</div>
</td>

View File

@ -290,7 +290,7 @@ function wc_save_order_items( $order_id, $items ) {
if ( isset( $items['shipping_method_id'] ) ) {
$get_values = array( 'shipping_method_id', 'shipping_method_title', 'shipping_method', 'shipping_cost' );
$get_values = array( 'shipping_method_id', 'shipping_method_title', 'shipping_method', 'shipping_cost', 'shipping_taxes' );
foreach ( $get_values as $value ) {
$$value = isset( $items[ $value ] ) ? $items[ $value ] : array();
@ -304,6 +304,7 @@ function wc_save_order_items( $order_id, $items ) {
$method_id = wc_clean( $shipping_method[ $item_id ][ $new_key ] );
$method_title = wc_clean( $shipping_method_title[ $item_id ][ $new_key ] );
$cost = wc_format_decimal( $shipping_cost[ $item_id ][ $new_key ] );
$ship_taxes = array_map( 'wc_format_decimal', $shipping_taxes[ $item_id ] );
$new_id = wc_add_order_item( $order_id, array(
'order_item_name' => $method_title,
@ -313,6 +314,7 @@ function wc_save_order_items( $order_id, $items ) {
if ( $new_id ) {
wc_add_order_item_meta( $new_id, 'method_id', $method_id );
wc_add_order_item_meta( $new_id, 'cost', $cost );
wc_add_order_item_meta( $new_id, 'taxes', $ship_taxes );
}
$order_shipping += $cost;
@ -324,6 +326,7 @@ function wc_save_order_items( $order_id, $items ) {
$method_id = wc_clean( $shipping_method[ $item_id ] );
$method_title = wc_clean( $shipping_method_title[ $item_id ] );
$cost = wc_format_decimal( $shipping_cost[ $item_id ] );
$ship_taxes = array_map( 'wc_format_decimal', $shipping_taxes[ $item_id ] );
$wpdb->update(
$wpdb->prefix . 'woocommerce_order_items',
@ -335,6 +338,7 @@ function wc_save_order_items( $order_id, $items ) {
wc_update_order_item_meta( $item_id, 'method_id', $method_id );
wc_update_order_item_meta( $item_id, 'cost', $cost );
wc_update_order_item_meta( $item_id, 'taxes', $ship_taxes );
$order_shipping += $cost;
}