WC_Abstract_Order::add_order_item_totals_tax_rows()protectedWC 1.0

Add total row for taxes.

Method of the class: WC_Abstract_Order{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->add_order_item_totals_tax_rows( $total_rows, $tax_display );
$total_rows(array) (required) (passed by reference — &)
Reference to total rows array.
$tax_display(string) (required)
Excl or incl tax display mode.

WC_Abstract_Order::add_order_item_totals_tax_rows() code WC 8.7.0

protected function add_order_item_totals_tax_rows( &$total_rows, $tax_display ) {
	// Tax for tax exclusive prices.
	if ( 'excl' === $tax_display && wc_tax_enabled() ) {
		if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) {
			foreach ( $this->get_tax_totals() as $code => $tax ) {
				$total_rows[ sanitize_title( $code ) ] = array(
					'label' => $tax->label . ':',
					'value' => $tax->formatted_amount,
				);
			}
		} else {
			$total_rows['tax'] = array(
				'label' => WC()->countries->tax_or_vat() . ':',
				'value' => wc_price( $this->get_total_tax(), array( 'currency' => $this->get_currency() ) ),
			);
		}
	}
}