Remove taxes from cart with a zero-rate.
This commit is contained in:
parent
85175ec849
commit
c501b1b59a
|
@ -1652,11 +1652,17 @@ class WC_Cart {
|
|||
*/
|
||||
public function remove_taxes() {
|
||||
$this->shipping_tax_total = $this->tax_total = 0;
|
||||
$this->taxes = $this->shipping_taxes = array();
|
||||
$this->subtotal = $this->subtotal_ex_tax;
|
||||
|
||||
foreach ( $this->cart_contents as $cart_item_key => $item )
|
||||
$this->cart_contents[ $cart_item_key ]['line_subtotal_tax'] = $this->cart_contents[ $cart_item_key ]['line_tax'] = 0;
|
||||
|
||||
// If true, zero rate is applied so '0' tax is displayed on the frontend rather than nothing.
|
||||
if ( apply_filters( 'woocommerce_cart_remove_taxes_apply_zero_rate', true ) ) {
|
||||
$this->taxes = $this->shipping_taxes = array( apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) => 0 );
|
||||
} else {
|
||||
$this->taxes = $this->shipping_taxes = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -548,8 +548,14 @@ class WC_Tax {
|
|||
* @return string
|
||||
*/
|
||||
public function get_rate_label( $key ) {
|
||||
global $wpdb;
|
||||
return apply_filters( 'woocommerce_rate_label', $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_name FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ), $key, $this );
|
||||
global $wpdb, $woocommerce;
|
||||
|
||||
$rate_name = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_name FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) );
|
||||
|
||||
if ( ! $rate_name )
|
||||
$rate_name = $woocommerce->countries->tax_or_vat();
|
||||
|
||||
return apply_filters( 'woocommerce_rate_label', $rate_name, $key, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue