'Adding addiotional email from products custom field
I am trying to add a new email to order confirmation. Now I am able to use the order's custom fields to ad a new extra email address. But i would like to use a custom field from the product instead.
Below is what I have done so far.
add_filter( 'woocommerce_email_recipient_new_order', 'additional_customer_email_recipient', 10, 2 ); // New Order
function additional_customer_email_recipient( $recipient, $order ) {
if ( ! is_a( $order, 'WC_Order' ) ) return $recipient;
$prod_id = get_the_ID();
$extra_mail = get_post_meta($prod_id,'extra_email',true);
$recipient = $extra_mail;
return $recipient;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
