WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Schemas

CartSchema::get_tax_lines() protected WC 1.0

Get tax lines from the cart and format to match schema.

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

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_tax_lines( $cart );
$cart(\WC_Cart) (required)
Cart class instance.

Code of CartSchema::get_tax_lines() WC 5.7.1

protected function get_tax_lines( $cart ) {
	$cart_tax_totals = $cart->get_tax_totals();
	$tax_lines       = [];

	foreach ( $cart_tax_totals as $cart_tax_total ) {
		$tax_lines[] = array(
			'name'  => $cart_tax_total->label,
			'price' => $this->prepare_money_response( $cart_tax_total->amount, wc_get_price_decimals() ),
			'rate'  => WC_Tax::get_rate_percent( $cart_tax_total->tax_rate_id ),
		);
	}

	return $tax_lines;
}