-
-
Save mikejolley/2263203 to your computer and use it in GitHub Desktop.
/** | |
* 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; | |
} |
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 );
function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields['delivery_date'] = array(
'label' => __( 'Pre-order' ),
'value' => get_post_meta( $order->id, 'delivery_date', true ),
);
$fields['message'] = array(
'label' => __( 'Message' ),
'value' => get_post_meta( $order->id, 'message', true ),
);
$fields['shipping_email'] = array(
'label' => __( 'Recipient Email' ),
'value' => get_post_meta( $order->id, 'shipping_email', true ),
);
$fields['delivery_instructions'] = array(
'label' => __( 'Special Delivery Instructions' ),
'value' => get_post_meta( $order->id, 'delivery_instructions', true ),
);
return $fields;
}
woocommerce_email_customer_details_fields doesn't work. I understand that woocommerce_email_order_meta_keys is depreciated, but it works...
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;
}
woocommerce_email_order_meta_keys - not properly!!!
woocommerce_email_customer_details_fields - properly!
//
add_filter('woocommerce_email_customer_details_fields', 'my_woocommerce_email_order_meta_keys', 10, 1);
function my_woocommerce_email_order_meta_keys($keys) {
$keys[] = 'you're text';
return $keys;
}