Skip to content

Posted in: General Snippets | View All

Important: Snippet Placement

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

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

The Main code snippet is:


So, using the above example the code would be:

You can repeat this section of code if you are adding multiple fields.
    $fields['hear_about_us'] = array(
        'label' => __( 'How did you hear about us?' ),
        'value' => get_post_meta( $order->id, 'hear_about_us', true ),
    );

Audit History

Passed | February 3, 2023 | By jcullen

Scroll To Top