WC_Cart_Totals::get_merged_taxes( bool $in_cents = false, array|string $types = array('items', 'fees', 'shipping') )
Get taxes merged by type.
Description Description
Parameters Parameters
- $in_cents
-
(Optional) If returned value should be in cents.
Default value: false
- $types
-
(Optional) Types to merge and return. Defaults to all.
Default value: array('items', 'fees', 'shipping')
Return Return
(array)
Source Source
File: includes/class-wc-cart-totals.php
protected function get_merged_taxes( $in_cents = false, $types = array( 'items', 'fees', 'shipping' ) ) { $items = array(); $taxes = array(); if ( is_string( $types ) ) { $types = array( $types ); } foreach ( $types as $type ) { if ( isset( $this->$type ) ) { $items = array_merge( $items, $this->$type ); } } foreach ( $items as $item ) { foreach ( $item->taxes as $rate_id => $rate ) { if ( ! isset( $taxes[ $rate_id ] ) ) { $taxes[ $rate_id ] = 0; } $taxes[ $rate_id ] += $this->round_line_tax( $rate ); } } return $in_cents ? $taxes : wc_remove_number_precision_deep( $taxes ); }
Changelog Changelog
Version | Description |
---|---|
3.2.0 | Introduced. |