# Add Custom Order Fields to WooCommerce Privacy Exports

> Includes extra checkout fields you store on orders (such as a VAT number or delivery notes) in the order section of personal data exports.

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

## Code

```php
// Order meta key => label in the export.
$wpide_woo_export_meta = array(
    '_billing_vat_number' => 'VAT number',
    '_delivery_notes'     => 'Delivery notes',
);

add_filter( 'woocommerce_privacy_export_order_personal_data_props', function ( $props ) use ( $wpide_woo_export_meta ) {
    foreach ( $wpide_woo_export_meta as $key => $label ) {
        $props[ 'wpide_meta_' . $key ] = $label;
    }

    return $props;
} );

add_filter( 'woocommerce_privacy_export_order_personal_data_prop', function ( $value, $prop, $order ) use ( $wpide_woo_export_meta ) {
    if ( 0 !== strpos( $prop, 'wpide_meta_' ) || ! is_a( $order, 'WC_Order' ) ) {
        return $value;
    }

    $key = substr( $prop, strlen( 'wpide_meta_' ) );

    return isset( $wpide_woo_export_meta[ $key ] ) ? (string) $order->get_meta( $key ) : $value;
}, 10, 3 );
```

## Notes

Use the order meta keys your checkout field plugin saves; keys starting with an underscore are fine.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add Custom Order Fields to WooCommerce Privacy Exports" 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/
