/** | |
* 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; | |
} |
This comment has been minimized.
This comment has been minimized.
tis - extracted for the docs http://www.woothemes.com/woocommerce-docs/snippets/add-a-custom-field-in-an-order-to-the-emails/ |
This comment has been minimized.
This comment has been minimized.
whereas $keys = array ? |
This comment has been minimized.
This comment has been minimized.
I purchased Checkout Field Editor and I added a new field. I see him during the purchase, but does not appear in the mail: http://i.imgur.com/owwD5S7.jpg I used this code: add_filter('woocommerce_email_order_meta_keys', 'billing_cfiscale'); function billing_cfiscale( $keys ) { |
This comment has been minimized.
This comment has been minimized.
Hi there. I purchased this plugin today (25 sites). I installed it and added in an extra field (label is Ship Date) under Shipping. I also added in the script above so that the new field would be added to the emails going out. However, adding in the above script did not add it to any email order receipt nor email to the admin. Please help. |
This comment has been minimized.
This comment has been minimized.
@seozones and @fabio-farolfi make sure you are using the name and not the label as the key in the above code. For example if I have a checkout field named my_example with label of "My Example" then for the fields to show in the admin emails the code would look like this: /** * 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_example'; return $keys; } That is how I got it to work for me ;) Cheers! |
This comment has been minimized.
This comment has been minimized.
I confirm the snippet works, but you have to use the field slug, not the label or the name. |
This comment has been minimized.
This comment has been minimized.
Thanks to everyone for helping with this addition. Question I have, how do I add more than one custom field? |
This comment has been minimized.
This comment has been minimized.
Found my own answer after doing a web search. Found the necessary info here: http://bit.ly/H0VPP4 |
This comment has been minimized.
This comment has been minimized.
Does still work for woocoommerce 2.1.6? I can't seem to get it working. Here's my code //display custom fields backend product creation function woo_add_custom_general_fields() { ';
woocommerce_wp_text_input( array( 'id' => 'amazon_code', 'label' => __('Amazon Coupon Code', 'woocommerce'), 'placeholder' => 'Enter Coupon Code', 'desc_tip' => 'true', 'description' => __('Enter Amazon Coupon Code', 'woocommerce') ) );
} } //add custom amazon coupon code to email |
This comment has been minimized.
This comment has been minimized.
The code is not works for WC 2.1.12 |
This comment has been minimized.
This comment has been minimized.
woocommerce_email_order_meta_keys - not properly!!! |
This comment has been minimized.
This comment has been minimized.
Can anyone see a problem with this? Any assistance much appreciated! add_filter('woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 ); |
This comment has been minimized.
This comment has been minimized.
woocommerce_email_customer_details_fields doesn't work. I understand that woocommerce_email_order_meta_keys is depreciated, but it works... |
This comment has been minimized.
This comment has been minimized.
Hi guys, How can I implement this code to send the custom field in the "Admin New Order Email"? |
This comment has been minimized.
This comment has been minimized.
@dimbert82 code like this:
|
This comment has been minimized.
roughly the same as https://gist.github.com/1547491