Plugin Contributor
Ewout
(@pomegranate)
Hi!
You could add an extra checkout field for this purpose using one of the many WooCommerce Checkout field editor plugins. You can then use a filter to add this address as CC to the email sent to the customer, following this guide. Here’s an example that does this for the Completed order email.
add_filter( 'woocommerce_email_headers', 'wpo_wcpdf_invoice_second_email', 10, 3 );
function wpo_wcpdf_invoice_second_email( $headers, $email_id, $object ) {
if ($email_id == 'customer_completed_order') {
// enter the name of the custom field in which the second email address is stored in place of 'xxx'
$email_address = $object->get_meta('xxx');
if (!empty($email_address)) {
$headers .= sprintf( "CC: %s \r\n", $email_address );
}
}
return $headers;
}
If you’re not sure which field name to sue in the above code (instead of ‘xxx’), check this guide: Finding WooCommerce Custom Fields
Hope that helps!
This is excellent work! case closed!