Skip to content

Instantly share code, notes, and snippets.

@nilsbosman
Last active February 11, 2021 12:50
Show Gist options
  • Save nilsbosman/b4bdf6e5be3b058c9551991393bfb72b to your computer and use it in GitHub Desktop.
Save nilsbosman/b4bdf6e5be3b058c9551991393bfb72b to your computer and use it in GitHub Desktop.
Add CC and BCC to WooCommerce Emails
<?php
// place this code in your functions.php file.
function add_cc_to_certain_emails( $headers, $id ) {
// Define the email type and check if true (You can use all woocommerce email types, for more info: https://docs.woocommerce.com/wc-apidocs/class-WC_Email.html)
if ( 'new_order' === $id ) {
$headers .= "Cc: FirstName LastName <fistname-lastname@mail.com>\r\n";
$headers .= "Bcc: FirstName LastName <fistname-lastname@mail.com>\r\n";
// You can add more extra email headers here. Make sure you use $headers .= otherwise it will overwrite the variable.
}
return $headers;
}
add_filter( 'woocommerce_email_headers', 'add_cc_to_certain_emails', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment