Skip to content

Commit

Permalink
Apply woocommerce_adjust_non_base_location_prices to all prices
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Sep 4, 2015
1 parent 31ed6c2 commit e08f8d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions includes/abstracts/abstract-wc-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ public function get_price_including_tax( $qty = 1, $price = '' ) {
$base_tax_amount = array_sum( $base_taxes );
$price = round( $price * $qty - $base_tax_amount, wc_get_price_decimals() );

} elseif ( $tax_rates !== $base_tax_rates ) {
} elseif ( $tax_rates !== $base_tax_rates && apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {

$base_taxes = WC_Tax::calc_tax( $price * $qty, $base_tax_rates, true );
$modded_taxes = WC_Tax::calc_tax( ( $price * $qty ) - array_sum( $base_taxes ), $tax_rates, false );
Expand Down Expand Up @@ -861,7 +861,7 @@ public function get_price_excluding_tax( $qty = 1, $price = '' ) {
$price = $this->get_price();
}

if ( $this->is_taxable() && get_option( 'woocommerce_prices_include_tax' ) === 'yes' ) {
if ( $this->is_taxable() && 'yes' === get_option( 'woocommerce_prices_include_tax' ) && apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {
$tax_rates = WC_Tax::get_base_tax_rates( $this->tax_class );
$taxes = WC_Tax::calc_tax( $price * $qty, $tax_rates, true );
$price = WC_Tax::round( $price * $qty - array_sum( $taxes ) );
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ public function calculate_totals() {
/**
* ADJUST TAX - Calculations when base tax is not equal to the item tax
*/
if ( $item_tax_rates !== $base_tax_rates ) {
if ( $item_tax_rates !== $base_tax_rates && apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {

// Work out a new base price without the shop's base tax
$taxes = WC_Tax::calc_tax( $line_price, $base_tax_rates, true, true );
Expand Down Expand Up @@ -1233,7 +1233,7 @@ public function calculate_totals() {
/**
* ADJUST TAX - Calculations when base tax is not equal to the item tax
*/
if ( $item_tax_rates !== $base_tax_rates && apply_filters( 'woocommerce_adjust_non_base_location_prices', false ) ) {
if ( $item_tax_rates !== $base_tax_rates && apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {

// Work out a new base price without the shop's base tax
$taxes = WC_Tax::calc_tax( $line_price, $base_tax_rates, true, true );
Expand Down
2 changes: 2 additions & 0 deletions woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

if ( ! class_exists( 'WooCommerce' ) ) :

add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );

/**
* Main WooCommerce Class
*
Expand Down

0 comments on commit e08f8d8

Please sign in to comment.