get_base_tax_rates() + filter. Closes #6668
This commit is contained in:
parent
b5f359b22a
commit
cb8fe34b4c
|
@ -768,7 +768,7 @@ class WC_Product {
|
|||
} else {
|
||||
|
||||
$tax_rates = WC_Tax::get_rates( $this->get_tax_class() );
|
||||
$base_tax_rates = WC_Tax::get_shop_base_rate( $this->tax_class );
|
||||
$base_tax_rates = WC_Tax::get_base_tax_rates( $this->tax_class );
|
||||
|
||||
if ( ! empty( WC()->customer ) && WC()->customer->is_vat_exempt() ) {
|
||||
|
||||
|
@ -811,7 +811,7 @@ class WC_Product {
|
|||
}
|
||||
|
||||
if ( $this->is_taxable() && get_option('woocommerce_prices_include_tax') === 'yes' ) {
|
||||
$tax_rates = WC_Tax::get_shop_base_rate( $this->tax_class );
|
||||
$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 ) );
|
||||
} else {
|
||||
|
|
|
@ -1039,7 +1039,7 @@ class WC_Cart {
|
|||
|
||||
// Get base tax rates
|
||||
if ( empty( $shop_tax_rates[ $_product->tax_class ] ) )
|
||||
$shop_tax_rates[ $_product->tax_class ] = $this->tax->get_shop_base_rate( $_product->tax_class );
|
||||
$shop_tax_rates[ $_product->tax_class ] = $this->tax->get_base_tax_rates( $_product->tax_class );
|
||||
|
||||
// Get item tax rates
|
||||
if ( empty( $tax_rates[ $_product->get_tax_class() ] ) )
|
||||
|
|
|
@ -337,12 +337,12 @@ class WC_Tax {
|
|||
// Prices excluding tax however should just not add any taxes, as they will be added during checkout.
|
||||
// The woocommerce_default_customer_address option (when set to base) is also used here.
|
||||
$matched_tax_rates = get_option( 'woocommerce_prices_include_tax' ) == 'yes' || get_option( 'woocommerce_default_customer_address' ) == 'base'
|
||||
? self::get_shop_base_rate( $tax_class )
|
||||
? self::get_base_tax_rates( $tax_class )
|
||||
: array();
|
||||
|
||||
}
|
||||
|
||||
return apply_filters('woocommerce_matched_rates', $matched_tax_rates, $tax_class);
|
||||
return apply_filters( 'woocommerce_matched_rates', $matched_tax_rates, $tax_class );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -351,14 +351,25 @@ class WC_Tax {
|
|||
* @param string Tax Class
|
||||
* @return array
|
||||
*/
|
||||
public static function get_shop_base_rate( $tax_class = '' ) {
|
||||
return self::find_rates( array(
|
||||
public static function get_base_tax_rates( $tax_class = '' ) {
|
||||
return apply_filters( 'woocommerce_base_tax_rates', self::find_rates( array(
|
||||
'country' => WC()->countries->get_base_country(),
|
||||
'state' => WC()->countries->get_base_state(),
|
||||
'postcode' => WC()->countries->get_base_postcode(),
|
||||
'city' => WC()->countries->get_base_city(),
|
||||
'tax_class' => $tax_class
|
||||
) );
|
||||
) ), $tax_class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for get_base_tax_rates()
|
||||
*
|
||||
* @deprecated 2.3
|
||||
* @param string Tax Class
|
||||
* @return array
|
||||
*/
|
||||
public static function get_shop_base_rate( $tax_class = '' ) {
|
||||
return self::get_base_tax_rates( $tax_class );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue