In WooCommerce, I want to add some custom fields on checkout which will be displayed under the billing section on the e-mail confirmation. My custom fields and their values, shown on the checkout form and on the order page on back end (WooCommerce -> Orders). So far everything works great.
The problem is that the e-mail that i receive does not contain the custom fields and their values.
Code shown below:
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_field_testing'] = array(
'label' => __('TestingField', 'woocommerce'),
'placeholder' => _x('TestingField', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('form-row-wide'),
'clear' => true
);
return $fields;
}
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order)
{
echo '<p><strong>'.__('TestingField').':</strong> ' . get_post_meta( $order->id, '_billing_field_testing', true ) . '</p>';
}
Please help.
Thanks in advance