WC_Cart_Totals::get_merged_taxes()
Get taxes merged by type.
Method of the class: WC_Cart_Totals{}
No Hooks.
Return
Array
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_merged_taxes( $in_cents, $types, fooo, foooo ) );
- $in_cents(true|false)
- If returned value should be in cents.
Default: false - $types(array|string)
- Types to merge and return.
Default: all - fooo (required)
- -
- foooo ) (required)
- -
Changelog
Since 3.2.0 | Introduced. |
WC_Cart_Totals::get_merged_taxes() WC Cart Totals::get merged taxes code WC 9.6.0
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 ); }