• Hello,

    Thank you for the useful plugin.

    I would like to add an attachment to the Order approved notification email that is sent to the client.

    One way I could do it is to add a code snippet to the functions.php file of the parent’s theme that would target this particular email.

    The code snippet I use is the following one:

    add_filter( 'woocommerce_email_attachments', 'attach_file_to_emails', 10, 4 );
     
    function attach_file_to_emails( $attachments, $email_id, $order, $email ) {
        $email_ids = array( 'WC_Customer_Order_Approved' );
        if ( in_array ( $email_id, $email_ids ) ) {
            $upload_dir = wp_upload_dir(); 
            $attachments[] = $upload_dir['basedir'] . "/2021/03/ticket.pdf"; 
        }
        return $attachments;
    }

    This way, the file ticket.pdf would be automatically included as the email attachment.

    However, this doesn’t work.

    I wonder if the approach is good and what is missing in the code?

    Thanks.

  • The topic ‘Add an attachment to the Order Approved Notification email’ is closed to new replies.