Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 82367

Why are the fees reset before calculating them?

$
0
0

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.


Viewing all articles
Browse latest Browse all 82367

Trending Articles