WC_Cart_Totals::calculate_fee_totals
Triggers the cart fees API, grabs the list of fees, and calculates taxes.
Note: This class sets the totals for the 'object' as they are calculated. This is so that APIs like the fees API can see these totals if needed.
Method of the class: WC_Cart_Totals{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->calculate_fee_totals();
Changelog
| Since 3.2.0 | Introduced. |
WC_Cart_Totals::calculate_fee_totals() WC Cart Totals::calculate fee totals code WC 10.3.5
protected function calculate_fee_totals() {
$this->get_fees_from_cart();
$this->set_total( 'fees_total', array_sum( wp_list_pluck( $this->fees, 'total' ) ) );
$this->set_total( 'fees_total_tax', array_sum( wp_list_pluck( $this->fees, 'total_tax' ) ) );
$this->cart->fees_api()->set_fees( wp_list_pluck( $this->fees, 'object' ) );
$this->cart->set_fee_total( wc_remove_number_precision_deep( array_sum( wp_list_pluck( $this->fees, 'total' ) ) ) );
$this->cart->set_fee_tax( wc_remove_number_precision_deep( array_sum( wp_list_pluck( $this->fees, 'total_tax' ) ) ) );
$this->cart->set_fee_taxes( wc_remove_number_precision_deep( $this->combine_item_taxes( wp_list_pluck( $this->fees, 'taxes' ) ) ) );
}