WC_Cart::get_taxes_totalpublicWC 1.0

Get tax row amounts with or without compound taxes includes.

Method of the class: WC_Cart{}

Hooks from the method

Returns

float. price

Usage

$WC_Cart = new WC_Cart();
$WC_Cart->get_taxes_total( $compound, $display );
$compound(true|false)
True if getting compound taxes.
Default: true
$display(true|false)
True if getting total to display.
Default: true

WC_Cart::get_taxes_total() code WC 11.0.1

public function get_taxes_total( $compound = true, $display = true ) {
	$taxes = $this->get_taxes();

	// Skip compounding taxes if requested.
	if ( ! $compound ) {
		$tax_rate_objects = wc_get_container()->get( TaxRateDataStore::class )->get_rate_objects_for_ids( array_keys( $taxes ) );
		foreach ( $taxes as $key => $tax ) {
			if ( WC_Tax::is_compound( $tax_rate_objects[ $key ] ?? $key ) ) {
				unset( $taxes[ $key ] );
			}
		}
	}

	$total = array_sum( $taxes );
	$total = $display ? wc_format_decimal( $total, wc_get_price_decimals() ) : $total;

	return apply_filters( 'woocommerce_cart_taxes_total', $total, $compound, $display, $this );
}