I'm trying to add an extra form field to woocommerce checkout, and populate it with an existing user meta value if exists, but I can't seem to get the value attribute to render.
$user_meta_billing_licence_number traces to the error log, and it will show up in the label if I append it to the label, and to the placeholder, if I append it to the placeholder, but not to the value attribute. What am I doing wrong?
add_filter('woocommerce_billing_fields', 'custom_billing_fields', 20 );
function custom_billing_fields( $fields ) {
// Add license field.
$user_id = get_current_user_id();
$user_meta_billing_licence_number = (string)get_user_meta( $user_id, 'billing_licence_number', true );
error_log('debug: line 117: billing_licence_number = '.$user_meta_billing_licence_number);
$fields['billing_licence_number'] = array(
'label' => __('License Number (for use on certificates)', 'woocommerce'),
'required' => false,
'class' => array('form-row-wide'),
'clear' => true,
'placeholder' => 'Recommended format: MA12345'.$user_meta_billing_licence_number,
'value' => $user_meta_billing_licence_number
);
return $fields;
}