# Show Custom Order Fields in Order Emails

> Adds the order details you choose, such as a delivery date or gift message saved by another plugin, to WooCommerce's order emails with friendly labels.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, email, order-meta, fields
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-email-order-meta-keys/

## Code

```php
$wpide_email_meta = array( // Meta key => array( label, admin only ).
    '_delivery_date' => array( 'Delivery date', false ),
    '_gift_message'  => array( 'Gift message', false ),
    '_source'        => array( 'Order source', true ),
);

add_filter( 'woocommerce_email_order_meta_fields', function ( $fields, $sent_to_admin, $order ) use ( $wpide_email_meta ) {
    foreach ( $wpide_email_meta as $key => $config ) {
        $value = $order->get_meta( $key );

        if ( '' === $value || is_array( $value ) || ( $config[1] && ! $sent_to_admin ) ) {
            continue;
        }

        $fields[ 'wpide_' . sanitize_key( $key ) ] = array(
            'label' => $config[0],
            'value' => wp_strip_all_tags( (string) $value ),
        );
    }

    return $fields;
}, 10, 3 );
```

## Notes

List meta keys and labels in $wpide_email_meta, and set the second value to true for details only the shop should see.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Custom Order Fields in Order Emails" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
