WC_Cart_Totals::get_tax_class_costs()
Get item costs grouped by tax class.
Description Description
Return Return
(array)
Source Source
File: includes/class-wc-cart-totals.php
protected function get_tax_class_costs() { $item_tax_classes = wp_list_pluck( $this->items, 'tax_class' ); $shipping_tax_classes = wp_list_pluck( $this->shipping, 'tax_class' ); $fee_tax_classes = wp_list_pluck( $this->fees, 'tax_class' ); $costs = array_fill_keys( $item_tax_classes + $shipping_tax_classes + $fee_tax_classes, 0 ); $costs['non-taxable'] = 0; foreach ( $this->items + $this->fees + $this->shipping as $item ) { if ( 0 > $item->total ) { continue; } if ( ! $item->taxable ) { $costs['non-taxable'] += $item->total; } elseif ( 'inherit' === $item->tax_class ) { $costs[ reset( $item_tax_classes ) ] += $item->total; } else { $costs[ $item->tax_class ] += $item->total; } } return array_filter( $costs ); }
Changelog Changelog
Version | Description |
---|---|
3.2.0 | Introduced. |