Skip to content

Instantly share code, notes, and snippets.

@ddemuth
Last active January 30, 2021 21:42
Show Gist options
  • Save ddemuth/3279872edbc8ad6be13418ea8a0aa79b to your computer and use it in GitHub Desktop.
Save ddemuth/3279872edbc8ad6be13418ea8a0aa79b to your computer and use it in GitHub Desktop.
Customize the email recipient
//WooCommerce Email Customizations
add_filter( 'woocommerce_email_recipient_customer_note', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_completed_order', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_invoice', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_processing_order', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
/**
* $recipient could be comma separated to send to additional people
* EX. $recipient .= ', $additonal_recipient';
*/
function fka_parent_email_recipient_filter_function($recipient, $order) {
$parent_email_recipient = get_post_meta( $order->id, 'Parent Email', true );
$recipient = $parent_email_recipient;
return $recipient;
}
@Hasan-Mahamud-Rana
Copy link

Hasan-Mahamud-Rana commented Aug 23, 2019

WordPress Version: 5.2.2
WooCommerce version: 3.7.0

add_filter( 'woocommerce_email_recipient_customer_note', 'termatech_email_recipient_filter_function', 10, 2);
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'termatech_email_recipient_filter_function', 10, 2);
add_filter( 'woocommerce_email_recipient_customer_invoice', 'termatech_email_recipient_filter_function', 10, 2);
add_filter( 'woocommerce_email_recipient_customer_processing_order', 'termatech_email_recipient_filter_function', 10, 2);
function termatech_email_recipient_filter_function($recipient, $order) {
$recipient .= ','. get_post_meta($order->get_id(), '_billing_nearest_dealer_email', true);
return $recipient;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment