Automattic\WooCommerce\StoreApi\Schemas\V1
CartSchema::get_tax_lines()
Get tax lines from the cart and format to match schema.
Метод класса: CartSchema{}
Хуков нет.
Возвращает
Массив
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_tax_lines( $cart );
- $cart(\WC_Cart) (обязательный)
- Cart class instance.
Код CartSchema::get_tax_lines() CartSchema::get tax lines WC 8.1.1
protected function get_tax_lines( $cart ) { $tax_lines = []; if ( 'itemized' !== get_option( 'woocommerce_tax_total_display' ) ) { return $tax_lines; } $cart_tax_totals = $cart->get_tax_totals(); $decimals = wc_get_price_decimals(); 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, $decimals ), 'rate' => WC_Tax::get_rate_percent( $cart_tax_total->tax_rate_id ), ); } return $tax_lines; }