WordPress at Your Fingertips
function is not described

WC_Cart_Totals::get_item_costs_by_tax_class() protected WC 3.2.0

Get item costs grouped by tax class.

{} 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_item_costs_by_tax_class();

Changelog

Since 3.2.0 Introduced.

Code of WC_Cart_Totals::get_item_costs_by_tax_class() WC 5.9.0

protected function get_item_costs_by_tax_class() {
	$tax_classes = array(
		'non-taxable' => 0,
	);

	foreach ( $this->items + $this->fees + $this->shipping as $item ) {
		if ( ! isset( $tax_classes[ $item->tax_class ] ) ) {
			$tax_classes[ $item->tax_class ] = 0;
		}

		if ( $item->taxable ) {
			$tax_classes[ $item->tax_class ] += $item->total;
		} else {
			$tax_classes['non-taxable'] += $item->total;
		}
	}

	return $tax_classes;
}