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

Note: 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.

Copy the following code to your theme functions.php then go to WooCommerce > Checkout Fields to add your newly created custom field.

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’:

WC-example-custom-field

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