mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/75256620/sending-order-notifications-to-the-user-to-the-billing-email-address-and-to-the
13 lines
623 B
Text
13 lines
623 B
Text
function custom_woocommerce_email_recipient( $recipient, $object, $email ) {
|
|
// Only target "new order" email notifications
|
|
if ( $email->id === 'new_order' ) {
|
|
// Get the user's billing email address
|
|
$billing_email = $object->get_billing_email();
|
|
// Get the user's customer profile email address
|
|
$profile_email = $object->get_user()->user_email;
|
|
// Add the customer profile email address to the recipient list
|
|
$recipient .= ',' . $profile_email;
|
|
}
|
|
return $recipient;
|
|
}
|
|
add_filter( 'woocommerce_email_recipient', 'custom_woocommerce_email_recipient', 10, 3 );
|