Augment order emails with custom information
In this small guide we’re going to add a custom field in the WooCommerce order administration page to allow store owners to include any extra information they want in emails sent to the client regarding their orders.
Install and activate a child theme
The first step on our process here is to create and install a child theme. If you are using one of our themes you can easily grab its child theme from our downloads section. If not, you can read our beginner’s guide on child themes to create your own. This step is essential in order to preserve our changes throughout theme updates.
Adding the custom field
In our example we will be adding a custom field to the admin order page which we will use to include a tracking code for the client to watch their package’s delivery route. We have added custom fields to WooCommerce products in many of our guides and the process is pretty similar here as well.
We use the woocommerce_admin_order_data_after_order_details hook to add our field in and the woocommerce_process_shop_order_meta one in order to save any data entered to it.
Our new field appears in the order details page as expected.
Include the new custom field to emails
Now let’s include the custom field to emails sent to the client.
We use the woocommerce_email_order_meta_fields hook to filter the email order meta fields and add our own. We just need a label for our field and its value. The value is pulled from the order’s meta and we need to make sure the meta key used (tracking_code in this case) matches the id used in the custom field added to the order admin page earlier. That’s it, now the new field will appear on any email sent to the customer.
Using the information from this guide we can easily add any field we want to the admin order page in and create more informative order related emails for our clients. Did you find this guide helpful? Let us know in the comments below.