Last active
June 1, 2019 17:50
-
-
Save mikejolley/2263203 to your computer and use it in GitHub Desktop.
WooCommerce - Add custom field (in an order) to the order emails
This file contains 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
/** | |
* Add the field to order emails | |
**/ | |
add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys'); | |
function my_woocommerce_email_order_meta_keys( $keys ) { | |
$keys['How did you hear about us?'] = 'hear_about_us'; | |
return $keys; | |
} |
Hi guys,
How can I implement this code to send the custom field in the "Admin New Order Email"?
@dimbert82
insert the code in your active theme or child theme functions.php
code like this:
add_filter( 'woocommerce_email_order_meta_fields', 'custom_order_mail_fields_callback', 10, 3 );
function custom_order_mail_fields_callback( $fields, $sent_to_admin, $order ) {
$fields['yourdata'] = array(
'label' => __( 'yourdata to display' ),
'value' => ' yourdata value',
);
}
return $fields;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
woocommerce_email_customer_details_fields doesn't work. I understand that woocommerce_email_order_meta_keys is depreciated, but it works...