WC_Cart_Totals::combine_item_taxes()
Combine item taxes into a single array, preserving keys.
Method of the class: WC_Cart_Totals{}
No Hooks.
Return
Array
.
Usage
// protected - for code of main (parent) or child class $result = $this->combine_item_taxes( $item_taxes );
- $item_taxes(array) (required)
- Taxes to combine.
Changelog
Since 3.2.0 | Introduced. |
WC_Cart_Totals::combine_item_taxes() WC Cart Totals::combine item taxes code WC 9.8.2
protected function combine_item_taxes( $item_taxes ) { $merged_taxes = array(); foreach ( $item_taxes as $taxes ) { foreach ( $taxes as $tax_id => $tax_amount ) { if ( ! isset( $merged_taxes[ $tax_id ] ) ) { $merged_taxes[ $tax_id ] = 0; } $merged_taxes[ $tax_id ] += $tax_amount; } } return $merged_taxes; }