Add a custom field (in an order) to the emails

This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, select a WooExpert or Developer for assistance. We are unable to provide support for customizations under our  Support Policy.

You can add any custom field to your order emails by hooking in and specifying the name of the custom field. This can be useful when used in conjunction with the Checkout Field Editor extension, or if you want to include things like the ‘transaction key’ from PayPal orders, for example.

* Add a custom field (in an order) to the emails
add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 );
function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields['meta_key'] = array(
'label' => __( 'Label' ),
'value' => get_post_meta( $order->id, 'meta_key', true ),
return $fields;

Here is an example using the Checkout Field Editor extension of the WooCommerce > Checkout Field settings for a custom field created labeled ‘hear_about_us’:


Using this example the code would be:

$fields['How did you hear about us?'] = 'hear_about_us';

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top