Correctly total and loop fee taxes Closes #4559

This commit is contained in:
Mike Jolley 2014-01-22 14:09:55 +00:00
parent ea1a82c612
commit e04fafcba9
1 changed files with 7 additions and 4 deletions

View File

@ -1838,11 +1838,14 @@ class WC_Cart {
// Get tax rates
$tax_rates = $this->tax->get_rates( $fee->tax_class );
$fee_taxes = $this->tax->calc_tax( $fee->amount, $tax_rates, false );
$fee->tax = $fee_taxes['total_tax'];
if ( ! empty( $fee_taxes ) ) {
$fee->tax = array_sum( $fee_taxes );
// Tax rows - merge the totals we just got
foreach ( array_keys( $this->taxes + $fee_taxes['taxes'] ) as $key ) {
$this->taxes[ $key ] = ( isset( $fee_taxes['taxes'][ $key ] ) ? $fee_taxes['taxes'][ $key ] : 0 ) + ( isset( $this->taxes[ $key ] ) ? $this->taxes[ $key ] : 0 );
// Tax rows - merge the totals we just got
foreach ( array_keys( $this->taxes ) as $key ) {
$this->taxes[ $key ] = ( isset( $fee_taxes['taxes'][ $key ] ) ? $fee_taxes['taxes'][ $key ] : 0 ) + ( isset( $this->taxes[ $key ] ) ? $this->taxes[ $key ] : 0 );
}
}
}
}