Make woocommerce checkout field Read Only

Solution for Make woocommerce checkout field Read Only
is Given Below:

I Am trying to make some checkout fields read-only on woocommerce. I came across the below snippet but it doesn’t work. please help me solve this. Thanks

add_action('woocommerce_checkout_fields','customization_readonly_billing_fields',10,1);
function customization_readonly_billing_fields($checkout_fields){
    $current_user = wp_get_current_user();;
    $user_id = $current_user->ID;
    foreach ( $checkout_fields['billing'] as $key => $field ){
        if($key == 'billing_country' || $key == 'billing_first_name' || $key == 'billing_last_name' || $key == 'billing_phone'){
            $key_value = get_user_meta($user_id, $key, true);
            if( strlen($key_value)>0){
                $checkout_fields['billing'][$key]['custom_attributes'] = array('readonly'=>'readonly');
            }
        }
    }
    return $checkout_fields;
}