Search

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

You can add any custom field to your order emails by hooking in and specifying the name of the custom field. This can 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:

$keys['How did you hear about us?'] = 'hear_about_us';
Back to the top