You can achieve this by adding a custom function to your WordPress theme's functions.php file. This function will hook into the WooCommerce checkout process and add the handling fee when the specific shipping method is selected. Below is an example code snippet to accomplish this:

// www.websitefunctions.com

add_action( 'woocommerce_cart_calculate_fees', 'add_handling_fee_based_on_shipping_method' );

function add_handling_fee_based_on_shipping_method() {

    // Change 'flat_rate:6' to the specific shipping method you want to target

    $targeted_shipping_method = 'flat_rate:6'; // Change this to your desired shipping method ID

    $handling_fee = 500; // Amount of handling fee

 

    // Check if the targeted shipping method is selected

    if ( WC()->session->get( 'chosen_shipping_methods' )[0] === $targeted_shipping_method ) {

        // Add the handling fee

        WC()->cart->add_fee( 'Handling Fee', $handling_fee );

    }

}

 

Make sure to replace 'flat_rate:6' with the ID of the shipping method you want to target. You can find the ID by inspecting the HTML of the checkout page when the shipping method is selected. Also, adjust $handling_fee to the amount you want to charge as a handling fee.

After adding this code to your theme's functions.php file, the handling fee will be added to the checkout total when the specified shipping method is selected.