I am trying to set the email address when have a new order. And I stored the new email
in wp_postmeta
.
How to get the $order_id
when using woocommerce_email_headers
?
I need to get the order_id
to use it with get_post_meta()
function.
Here is my code:
function techie_custom_wooemail_headers( $headers, $object) {
$email = get_post_meta( $order_id, '_approver_email', true );
// Replace the emails below to your desire email
$emails = array('eee@hotmail.com', $email);
switch($object) {
case 'new_order':
$headers .= 'Bcc: ' . implode(',', $emails) . "\r\n";
break;
case 'customer_processing_order':
$headers .= 'Bcc: ' . implode(',', $emails) . "\r\n";
break;
case 'customer_completed_order':
case 'customer_invoice':
$headers .= 'Bcc: ' . implode(',', $emails) . "\r\n";
break;
default:
}
return $headers;
}
add_filter( 'woocommerce_email_headers', 'techie_custom_wooemail_headers', 10, 2);
How do I get back the data?
Thanks.