Tweak logic

This commit is contained in:
Mike Jolley 2015-12-23 12:50:28 +00:00
parent 00341a30b3
commit 4bf40cedb1
1 changed files with 13 additions and 9 deletions

View File

@ -683,9 +683,10 @@ abstract class WC_Abstract_Order {
}
// Now calculate shipping tax
$matched_tax_rates = array();
$shipping_methods = $this->get_shipping_methods();
if ( ! empty( $shipping_methods ) ) {
$matched_tax_rates = array();
$tax_rates = WC_Tax::find_rates( array(
'country' => $country,
'state' => $state,
@ -693,18 +694,21 @@ abstract class WC_Abstract_Order {
'city' => $city,
'tax_class' => ''
) );
}
if ( ! empty( $tax_rates ) ) {
foreach ( $tax_rates as $key => $rate ) {
if ( isset( $rate['shipping'] ) && 'yes' === $rate['shipping'] ) {
$matched_tax_rates[ $key ] = $rate;
if ( ! empty( $tax_rates ) ) {
foreach ( $tax_rates as $key => $rate ) {
if ( isset( $rate['shipping'] ) && 'yes' === $rate['shipping'] ) {
$matched_tax_rates[ $key ] = $rate;
}
}
}
}
$shipping_taxes = WC_Tax::calc_shipping_tax( $this->order_shipping, $matched_tax_rates );
$shipping_tax_total = WC_Tax::round( array_sum( $shipping_taxes ) );
$shipping_taxes = WC_Tax::calc_shipping_tax( $this->order_shipping, $matched_tax_rates );
$shipping_tax_total = WC_Tax::round( array_sum( $shipping_taxes ) );
} else {
$shipping_taxes = array();
$shipping_tax_total = 0;
}
// Save tax totals
$this->set_total( $shipping_tax_total, 'shipping_tax' );