WordPress at Your Fingertips
function is not described

WC_Cart_Totals::calculate_fee_totals() protected WC 3.2.0

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.

{} It's a method of the class: WC_Cart_Totals{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->calculate_fee_totals();

Changelog

Since 3.2.0 Introduced.

Code of WC_Cart_Totals::calculate_fee_totals() WC 5.9.0

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' ) ) ) );
}