Created
September 29, 2014 09:10
-
-
Save woogist/c3c13c03a1fdc4b9c823 to your computer and use it in GitHub Desktop.
WooCommerce - add extra checkout fields to WooCommerce emails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the field to order emails | |
**/ | |
add_filter('woocommerce_email_order_meta_keys', 'my_custom_checkout_field_order_meta_keys'); | |
function my_custom_checkout_field_order_meta_keys( $keys ) { | |
$keys[] = 'My Field 1'; | |
$keys[] = 'My Field 2'; | |
return $keys; | |
} |
Are there any version requirements for this? I'm running on 2.1.12 and my custom fields are not coming over in the email.
I have the same problem. Does not receive the cutom fields in the email.
It is so good to know I'm not the only one who cannot get this to work. I've been thinking I'm going nuts for the last hour.
Hello everybody ! I found this post on Github https://gist.github.com/ChromeOrange/3905785 and it solved my problem: my custom fields are now displaying in the email. I just needed to leave the key empty: $keys[]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would adjust this to:
As this produces a more readable result:
My Field 1: Some value
My Field 2: Another value
instead of
_my_field_1: Some value
_my_field_2: Another value