save and display shipping taxes in order items meta box

This commit is contained in:
claudiosmweb 2014-07-20 00:32:52 -03:00
parent 6176cb6b77
commit 3a28c56876
5 changed files with 29 additions and 6 deletions

View File

@ -224,6 +224,10 @@ abstract class WC_Abstract_Order {
wc_add_order_item_meta( $item_id, 'method_id', $shipping_rate->id );
wc_add_order_item_meta( $item_id, 'cost', wc_format_decimal( $shipping_rate->cost ) );
// Save shipping taxes - Since 2.2
$taxes = array_map( 'wc_format_decimal', $shipping_rate->taxes );
wc_add_order_item_meta( $item_id, 'taxes', $taxes );
do_action( 'woocommerce_order_add_shipping', $this->id, $item_id, $shipping_rate );
// Update total

View File

@ -32,7 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php
if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) :
$line_tax_data = isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '';
$tax_data = maybe_unserialize( $line_tax_data );
$tax_data = maybe_unserialize( $line_tax_data );
foreach ( $order_taxes as $tax_item ) :
$tax_item_id = $tax_item['rate_id'];

View File

@ -178,7 +178,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php
if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) :
$line_tax_data = isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '';
$tax_data = maybe_unserialize( $line_tax_data );
$tax_data = maybe_unserialize( $line_tax_data );
foreach ( $order_taxes as $tax_item ) :
$tax_item_id = $tax_item['rate_id'];

View File

@ -54,11 +54,30 @@ if ( ! defined( 'ABSPATH' ) ) {
</div>
</td>
<?php if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) : for ( $i = 0; $i < count( $order_taxes ); $i++ ) : ?>
<?php
if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) :
$shipping_taxes = isset( $item['taxes'] ) ? $item['taxes'] : '';
$tax_data = maybe_unserialize( $shipping_taxes );
<td class="line_tax" width="1%"></td>
foreach ( $order_taxes as $tax_item ) :
$tax_item_id = $tax_item['rate_id'];
$tax_item_total = isset( $tax_data[ $tax_item_id ] ) ? $tax_data[ $tax_item_id ] : '';
<?php endfor; endif; ?>
?>
<td class="line_tax" width="1%">
<div class="view">
<?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" />
</div>
</td>
<?php
endforeach;
endif;
?>
<td class="wc-order-item-refund-quantity" width="1%" style="display: none;"></td>

View File

@ -54,4 +54,4 @@ class WC_Shipping_Rate {
}
return $taxes;
}
}
}