Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Hey Eric,

    Yep, but it’d be more efficient to not use this plugin. Could just add a little snippet to your child theme’s functions.php file to add a fee to each order:

    function woo_add_cart_fee() {
    	WC()->cart->add_fee( __('Custom', 'woocommerce'), 5 );
    }
    add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' );
    Thread Starter ericbullet

    (@ericbullet)

    Thanks.

    and that would apply to each product in the cart?

    Plugin Author Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Hey Eric,

    Oh, no that would just be a one-time fee regardless of the products in the cart. If you need to fee the multiply by the number of products in the cart, this snippet should do the trick:

    function woo_add_cart_fee() {
    	$cart_quantity = WC()->cart->cart_contents_count;
    	$fee_cost = 5;
    
    	WC()->cart->add_fee( __('Custom Fee', 'woocommerce'), $fee_cost * $cart_quantity );
    }
    add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' );
    Thread Starter ericbullet

    (@ericbullet)

    ty

    Hi Eric,

    I used the above function and it works. The only problem is that any coupons and shipping calculations don’t include this added fee. If a customer used a 100% off discount coupon, for example, the cart would go to $0 but the added fee would still be there.

    Do you have any idea how we can modify the code?

    Thanks a lot!
    Kirby

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘I want to always have the same fee per product’ is closed to new replies.