How to translate text in function.php with WPML [closed]

It should suffice to add a __() around your translatable text:

add_action( 'woocommerce_cart_calculate_fees', 'custom_handling_fee', 10, 1 );
function custom_handling_fee ( $cart ) {

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

    if ( 'cod' === WC()->session->get('chosen_payment_method') ) {
        $fee = 10;
        $cart->add_fee( __('Cash On Delivery'), $fee, true );
    }
}

You can then scan your theme or plugin for strings in WPML: https://wpml.org/documentation/getting-started-guide/theme-localization/
and then use the WPML string translation.