WC_Tax::calc_tax()public staticWC 1.0

Calculate tax for a line.

Method of the class: WC_Tax{}

Hooks from the method


Array. Array of rates + prices after tax.


$result = WC_Tax::calc_tax( $price, $rates, $price_includes_tax, $deprecated );
$price(float) (required)
Price to calc tax on.
$rates(array) (required)
Rates to apply.
Whether the passed price has taxes included.
Default: false
Whether to suppress any rounding from taking place. No longer used here.
Default: false

WC_Tax::calc_tax() code WC 8.3.0

public static function calc_tax( $price, $rates, $price_includes_tax = false, $deprecated = false ) {
	if ( $price_includes_tax ) {
		$taxes = self::calc_inclusive_tax( $price, $rates );
	} else {
		$taxes = self::calc_exclusive_tax( $price, $rates );
	return apply_filters( 'woocommerce_calc_tax', $taxes, $price, $rates, $price_includes_tax, $deprecated );