Add a surcharge to cart and checkout – uses fees API

[ad_1]

add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
  global $woocommerce;

	if ( is_admin() && ! defined( 'DOING_AJAX' ) )
		return;

	$percentage = 0.0195;
	$totalCCExpense = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;	
	$surcharge = ($totalCCExpense / 3) * 2; // They pay 2/3 of the handling fee, we pay 1/3.
	$woocommerce->cart->add_fee( '& Handling', round($surcharge, 2), true, '' );

}

The code above is what I did to add a handling charge to the orders. We have to manually do the orders, so I just add a small charge and have the customer pay 2/3 of that small fee, to recoup our loss of hiring the person to manually process orders. it does not cover it all, but helps us a tiny bit… But my question is…

I was able to successfully add a handling charge to the main order, but when it shows the future subscription order, it does not include the handling charge. How do I have it add it to both?

Here is the result of the cart when I added a product to it:


& Handling $1.02
Tax $6.33
Total $85.87
Recurring totals
Subtotal $62.32 / month
Shipping
UPS Ground: $16.20 / month
UPS Next Day Air: $67.54 / month
UPS 2nd Day Air: $31.41 / month
Tax $6.22 / month
Recurring total $84.74 / month
First renewal: August 7, 2023

See it did not add that to the Recurring Totals…

is there another function I can use to add it to the subscription part?
I got the code from:

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer