I am trying to send a PDF file to shop admin once the new order is placed. The issue with woocommerce_email_attachments
hook is that email is sent to both custo
The $id
is the WC_Email
ID that you can use to target a specific email notification like "New order" that is sent to admin when an Order have been successfully placed, this way:
add_filter( 'woocommerce_email_attachments', 'attach_order_notice', 10, 3 );
function attach_order_notice ( $attachments, $email_id, $order )
{
// Only for "New Order" email notification (for admin)
if( $email_id == 'new_order' ){
$attachments[] = get_template_directory() . '/notice.pdf';
}
return $attachments;
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and working