By the following code I'm able to add 3% Additional fees on user select Payment Method COD.
<?php
add_action('woocommerce_cart_calculate_fees', 'wcc_apply_cod_payment_gateway_fee');
function wcc_apply_cod_payment_gateway_fee(){
if (is_admin() && !defined('DOING_AJAX')) {
return;
}
$chosen_payment_method = WC()->session->get('chosen_payment_method');
if ($chosen_payment_method == 'cod') {
$cart_total = WC()->cart->cart_contents_total;
$amount = ($cart_total * 3)/100;
$amount = '+'.$amount;
$label = __( 'Cod 3% Fee', 'txtdomain' );
WC()->cart->add_fee( $label, $amount, true, 'standard' );
}
}
With this code Additional Fees message showing on Cart and Checkout both pages and I want to display it only on the WooCommerce Checkout page and not on The Cart page.