Howto add attachments to woocommerce e-mails

Posted on February 11, 2015
Attach files to any woocommerce email.

add_filter( 'woocommerce_email_attachments', '_custom_attach_file', 10, 3);

function _custom_attach_file ( $attachments, $status , $order )
{
     // attach file only when the order resides in the following statusses
     $allowed_statuses = array( 'customer_processing_order' );

     if (isset( $status ) && in_array($status, $allowed_statuses))
     {
          $your_path = dirname(__FILE__) . '/desired_folder_within_plugin/testfile.pdf';
          $attachments[] = $your_path;
     }

     return $attachments;
}

No Replies to "Howto add attachments to woocommerce e-mails"