Attach files to WooCommerce emails

How to attach a file to a WooCommerce order email.

I went searching online as I had to include an pdf document to the order email. I found what I needed at the Business Bloomer web site.

This is the code I added as a code snippet.

/**
 * @snippet       File Attachment @ WooCommerce Emails
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @testedwith    WooCommerce 7
 * @community     https://businessbloomer.com/club/
 */
 
add_filter( 'woocommerce_email_attachments', 'bbloomer_attach_pdf_to_emails', 10, 4 );
 
function bbloomer_attach_pdf_to_emails( $attachments, $email_id, $order, $email ) {
    $email_ids = array( 'new_order', 'customer_processing_order' );
    if ( in_array ( $email_id, $email_ids ) ) {
        $upload_dir = wp_upload_dir();
        $attachments[] = $upload_dir['basedir'] . "/Angreskjema-Gullhuset.pdf";
    }
    return $attachments;
}

This is the result when ordering with a Hotmail or Outlook email.

Attach file to WooCommerce order email
Attach file to WooCommerce order email.

Various Resources

https://www.businessbloomer.com/woocommerce-attach-file-pdf-emails/

https://webroomtech.com/add-an-attachment-in-woocommerce-emails/

https://www.damiencarbery.com/2021/05/attach-files-to-woocommerce-order-email

https://woocrmconnector.com/how-to-add-custom-attachments-to-woocommerce-emails-easily/

https://github.com/woocommerce/woocommerce/issues/54659

Angre skjema lenker / In Norway one can change ones mind in relation to purchases made.
One would fill out out a specific form and include it in the package and or email.

https://lovdata.no/dokument/NL/lov/2014-06-20-27/KAPITTEL_6#KAPITTEL_6

https://www.forbrukertilsynet.no/lov-og-rett/angrerettloven

https://skjema-no.com/angrerettskjema/

https://webforumet.no/forum/threads/angrerettskjema-i-woocommerce.19960/page-3

https://webforumet.no/forum/threads/angrerettskjema-i-woocommerce.19960/page-3

Share the article:

Leave a Reply

Your email address will not be published. Required fields are marked *