I need to show an text input field when customers select BACS gateway and I would like the input field value to be appended to orders and email notifications.
I am using Additional field on checkout for specific payment gateway in Woocommerce answer code where I have changed the select field to an input text field:
add_filter( 'woocommerce_gateway_description', 'gateway_bacs_custom_fields', 20, 2 );
function gateway_bacs_custom_fields( $description, $method_id ){
//
if( $method_id == 'bacs' ){
ob_start(); // Start buffering
echo '<div class="bacs-fields" style="padding:10px 0;">';
woocommerce_form_field( 'field_slug', array(
'type' => 'text',
'label' => __("Udfyld EAN", "woocommerce"),
'class' => array('form-row-wide'),
'required' => true,
), '');
echo '<div>';
$description .= ob_get_clean(); // Append buffered content
}
return $description;
}
It works fine on checkout page where it displays the field.
But the inputted text value is not being saved to orders and email notifications.
How to save and append this inputted text value on orders and email notifications?