WordPress at Your Fingertips
function is not described

WC_Cart_Totals::get_merged_taxes() protected WC 3.2.0

Get taxes merged by type.

{} It's a method of the class: WC_Cart_Totals{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_merged_taxes( $in_cents, $types, fooo, foooo ) );
$in_cents(true|false)
If returned value should be in cents.
Default: false
$types(array|string)
Types to merge and return.
Default: all
fooo (required)
-
foooo ) (required)
-

Changelog

Since 3.2.0 Introduced.

Code of WC_Cart_Totals::get_merged_taxes() WC 5.9.0

protected function get_merged_taxes( $in_cents = false, $types = array( 'items', 'fees', 'shipping' ) ) {
	$items = array();
	$taxes = array();

	if ( is_string( $types ) ) {
		$types = array( $types );
	}

	foreach ( $types as $type ) {
		if ( isset( $this->$type ) ) {
			$items = array_merge( $items, $this->$type );
		}
	}

	foreach ( $items as $item ) {
		foreach ( $item->taxes as $rate_id => $rate ) {
			if ( ! isset( $taxes[ $rate_id ] ) ) {
				$taxes[ $rate_id ] = 0;
			}
			$taxes[ $rate_id ] += $this->round_line_tax( $rate );
		}
	}

	return $in_cents ? $taxes : wc_remove_number_precision_deep( $taxes );
}