Upon completion of the WooCommerce Bookings order I'd like to CC the resource (post type bookable_resource
) that was assigned/selected/associated with the order. Then repeat the CC during the booking reminder. I've tried a hand-full of ideas but the code below (obviously incorrect) is where I stopped at.
Any thoughts on how to accomplish this?
function cc_resource_order( $headers, $email_id, $order) {
if ( 'customer_completed_order' == $email_id) {
$headers .= "Bcc: Name <this-works@thedomain.com>\r\n";
$headers .= "Cc: Name <this-works-too@anotherdomain.com>\r\n";
if (( 'bookable_resource' == get_post_type() ) && (get_the_ID() == 123456)){
$headers .= "Cc: Name <this-doesnt-work@samedomain.com>\r\n";
}
elseif (( 'bookable_resource' == get_post_type() ) && (get_the_ID() == 654321)){
$headers .= "Cc: Name <this-too-doesnt-work@samedomain.com>\r\n";
}
}
return $headers;
}
add_filter( 'woocommerce_email_headers', 'cc_resource_order', 9999, 3 );
function cc_resource_reminder( $headers, $email_id, $order) {
if ( 'booking_reminder' == $email_id) {
$headers .= "Bcc: Name <this-works@thedomain.com>\r\n";
$headers .= "Cc: Name <this-works-too@anotherdomain.com>\r\n";
if (( 'bookable_resource' == get_post_type() ) && (get_the_ID() == 123456)){
$headers .= "Cc: Name <this-doesnt-work@samedomain.com>\r\n";
}
elseif (( 'bookable_resource' == get_post_type() ) && (get_the_ID() == 654321)){
$headers .= "Cc: Name <nope-here-too@samedomain.com>\r\n";
}
}
return $headers;
}
add_filter( 'woocommerce_email_headers', 'cc_resource_reminder', 9999, 3 );