WC_Abstract_Order::get_tax_totals()publicWC 1.0

Get taxes, merged by code, formatted ready for output.

Method of the class: WC_Abstract_Order{}

Return

Array.

Usage

$WC_Abstract_Order = new WC_Abstract_Order();
$WC_Abstract_Order->get_tax_totals();

WC_Abstract_Order::get_tax_totals() code WC 8.7.0

public function get_tax_totals() {
	$tax_totals = array();

	foreach ( $this->get_items( 'tax' ) as $key => $tax ) {
		$code = $tax->get_rate_code();

		if ( ! isset( $tax_totals[ $code ] ) ) {
			$tax_totals[ $code ]         = new stdClass();
			$tax_totals[ $code ]->amount = 0;
		}

		$tax_totals[ $code ]->id               = $key;
		$tax_totals[ $code ]->rate_id          = $tax->get_rate_id();
		$tax_totals[ $code ]->is_compound      = $tax->is_compound();
		$tax_totals[ $code ]->label            = $tax->get_label();
		$tax_totals[ $code ]->amount          += (float) $tax->get_tax_total() + (float) $tax->get_shipping_tax_total();
		$tax_totals[ $code ]->formatted_amount = wc_price( $tax_totals[ $code ]->amount, array( 'currency' => $this->get_currency() ) );
	}

	if ( apply_filters( 'woocommerce_order_hide_zero_taxes', true ) ) {
		$amounts    = array_filter( wp_list_pluck( $tax_totals, 'amount' ) );
		$tax_totals = array_intersect_key( $tax_totals, $amounts );
	}

	return apply_filters( 'woocommerce_order_get_tax_totals', $tax_totals, $this );
}