I am trying to populate a custom field called "Customer Type" current user role. The custom field is displayed on my checkout page. I tried the below in my functions.php of my child theme and thought it would work but it does nothing. Can anyone tell me what I might be doing wrong?
$user = wp_get_current_user();
function onboarding_update_fields( $fields = array() ) {
$fields['customertype'] = $user;
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'onboarding_update_fields' );