WC_Abstract_Order::get_tax_totals
Get taxes, merged by code, formatted ready for output.
Метод класса: WC_Abstract_Order{}
Возвращает
Массив.
Использование
$WC_Abstract_Order = new WC_Abstract_Order(); $WC_Abstract_Order->get_tax_totals();
Код WC_Abstract_Order::get_tax_totals() WC Abstract Order::get tax totals WC 10.4.3
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 );
}