How to add a percentage based surcharge (plus tax of surcharge) to all transactions
Solution 1:
This should be 5% of the subtotal then 20% of that 5%...
add_action( 'woocommerce_cart_calculate_fees','custom_adminfee_surcharge' );
function custom_adminfee_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
$percentage = ( $woocommerce->cart->subtotal + $woocommerce->cart->shipping_total ) * 0.05;
$surcharge = $percentage * 0.20;
$total_charges = $percentage + $surcharge;
$woocommerce->cart->add_fee( 'Surcharge', $total_charges, true, '' );
}