Replies: 0
Within the cart class you have the calculate_fees() function.
/**
* Calculate fees.
*/
public function calculate_fees() {
<strong>// Reset fees before calculation
$this->fee_total = 0;
$this->fees = array();</strong>
// Fire an action where developers can add their fees
do_action( 'woocommerce_cart_calculate_fees', $this );
// If fees were added, total them and calculate tax
if ( ! empty( $this->fees ) ) {
....
....
I was hoping to add fees to the cart using WC()->cart->add_fee()
like you would do using WC()->cart->add_discount()
, but because they are reset every time they are calculated, the only way is to use the hook.
Just trying to understand the logic.