woocommerce_shipping_tax_class filter-hookWC 10.5.0

Filters the shipping tax class before calculating tax rates.

This filter allows plugins to modify or replace the shipping tax class that will be used to calculate shipping tax rates. It fires after core logic determines the tax class but before rates are looked up.

Usage

add_filter( 'woocommerce_shipping_tax_class', 'wp_kama_woocommerce_shipping_tax_class_filter', 10, 4 );

/**
 * Function for `woocommerce_shipping_tax_class` filter-hook.
 * 
 * @param string|null      $tax_class The tax class determined by core logic. Can be null, empty string (standard), or a tax class slug.
 * @param WC_Cart|null     $cart      The cart object containing all cart items, or null if not available.
 * @param WC_Customer|null $customer  The customer object, or null if not available.
 * @param array            $location  The tax location array [country, state, postcode, city].
 *
 * @return string|null
 */
function wp_kama_woocommerce_shipping_tax_class_filter( $tax_class, $cart, $customer, $location ){

	// filter...
	return $tax_class;
}
$tax_class(string|null)
The tax class determined by core logic. Can be null, empty string (standard), or a tax class slug.
$cart(WC_Cart|null)
The cart object containing all cart items, or null if not available.
$customer(WC_Customer|null)
The customer object, or null if not available.
$location(array)
The tax location array [country, state, postcode, city].

Changelog

Since 10.5.0 Introduced.

Where the hook is called

WC_Tax::get_shipping_tax_rates()
woocommerce_shipping_tax_class
woocommerce/includes/class-wc-tax.php 617
$tax_class = apply_filters( 'woocommerce_shipping_tax_class', $tax_class, $cart, $customer, $location );

Where the hook is used in WooCommerce

Usage not found.