parent
a4a421a86b
commit
96603720ca
|
@ -974,8 +974,14 @@ function wc_get_price_including_tax( $product, $args = array() ) {
|
|||
if ( ! wc_prices_include_tax() ) {
|
||||
$tax_rates = WC_Tax::get_rates( $product->get_tax_class() );
|
||||
$taxes = WC_Tax::calc_tax( $line_price, $tax_rates, false );
|
||||
$tax_amount = WC_Tax::get_tax_total( $taxes );
|
||||
$return_price = round( $line_price + $tax_amount, wc_get_price_decimals() );
|
||||
|
||||
if ( 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
|
||||
$taxes_total = array_sum( $taxes );
|
||||
} else {
|
||||
$taxes_total = array_sum( array_map( 'wc_round_tax_total', $taxes ) );
|
||||
}
|
||||
|
||||
$return_price = round( $line_price + $taxes_total, wc_get_price_decimals() );
|
||||
} else {
|
||||
$tax_rates = WC_Tax::get_rates( $product->get_tax_class() );
|
||||
$base_tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) );
|
||||
|
@ -986,8 +992,14 @@ function wc_get_price_including_tax( $product, $args = array() ) {
|
|||
*/
|
||||
if ( ! empty( WC()->customer ) && WC()->customer->get_is_vat_exempt() ) { // @codingStandardsIgnoreLine.
|
||||
$remove_taxes = apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ? WC_Tax::calc_tax( $line_price, $base_tax_rates, true ) : WC_Tax::calc_tax( $line_price, $tax_rates, true );
|
||||
$remove_tax = array_sum( $remove_taxes );
|
||||
$return_price = round( $line_price - $remove_tax, wc_get_price_decimals() );
|
||||
|
||||
if ( 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
|
||||
$remove_taxes_total = array_sum( $remove_taxes );
|
||||
} else {
|
||||
$remove_taxes_total = array_sum( array_map( 'wc_round_tax_total', $remove_taxes ) );
|
||||
}
|
||||
|
||||
$return_price = round( $line_price - $remove_taxes_total, wc_get_price_decimals() );
|
||||
|
||||
/**
|
||||
* The woocommerce_adjust_non_base_location_prices filter can stop base taxes being taken off when dealing with out of base locations.
|
||||
|
@ -997,7 +1009,16 @@ function wc_get_price_including_tax( $product, $args = array() ) {
|
|||
} elseif ( $tax_rates !== $base_tax_rates && apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {
|
||||
$base_taxes = WC_Tax::calc_tax( $line_price, $base_tax_rates, true );
|
||||
$modded_taxes = WC_Tax::calc_tax( $line_price - array_sum( $base_taxes ), $tax_rates, false );
|
||||
$return_price = round( $line_price - array_sum( $base_taxes ) + wc_round_tax_total( array_sum( $modded_taxes ), wc_get_price_decimals() ), wc_get_price_decimals() );
|
||||
|
||||
if ( 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
|
||||
$base_taxes_total = array_sum( $base_taxes );
|
||||
$modded_taxes_total = array_sum( $modded_taxes );
|
||||
} else {
|
||||
$base_taxes_total = array_sum( array_map( 'wc_round_tax_total', $base_taxes ) );
|
||||
$modded_taxes_total = array_sum( array_map( 'wc_round_tax_total', $modded_taxes ) );
|
||||
}
|
||||
|
||||
$return_price = round( $line_price - $base_taxes_total + $modded_taxes_total, wc_get_price_decimals() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1036,7 +1057,14 @@ function wc_get_price_excluding_tax( $product, $args = array() ) {
|
|||
$tax_rates = WC_Tax::get_rates( $product->get_tax_class() );
|
||||
$base_tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) );
|
||||
$remove_taxes = apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ? WC_Tax::calc_tax( $line_price, $base_tax_rates, true ) : WC_Tax::calc_tax( $line_price, $tax_rates, true );
|
||||
$return_price = $line_price - array_sum( $remove_taxes );
|
||||
|
||||
if ( 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
|
||||
$remove_taxes_total = array_sum( $remove_taxes );
|
||||
} else {
|
||||
$remove_taxes_total = array_sum( array_map( 'wc_round_tax_total', $remove_taxes ) );
|
||||
}
|
||||
|
||||
$return_price = round( $line_price - $remove_taxes_total, wc_get_price_decimals() );
|
||||
} else {
|
||||
$return_price = $line_price;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue