Skip to content
GPLWP Guides

How to attach files to WooCommerce emails

WooCommerce Time About 20 minutes 6 steps Updated 29 Oct 2026

WOOCOMMERCE
The short answer

WooCommerce does not provide a general setting for attaching arbitrary files to order emails. You can add a fixed file with the `woocommerce_email_attachments` filter, but product-specific or status-based attachments usually need an extension. Downloadable products are different: they send protected download links rather than email attachments.

The route
  1. 01Choose attachment or download link
  2. 02Use the manual code route
  3. 03Limit which emails receive it
  4. 04Handle product-specific files properly
  5. 05Test the exact customer email
  6. 06Use a plugin for the fast way

What you need

  • A WooCommerce store with administrator access
  • The file you want to attach, stored on the server
  • A staging site or recent backup if adding custom code
  • A test email address you can access

Choose attachment or download link

First decide whether the customer truly needs an email attachment. If the file is a purchased digital product, edit the product and enable Downloadable, then add the file under Downloadable files. WooCommerce sends the customer a download link in the order email and can also show it under My account → Downloads. This is usually safer for large files and lets you control download limits and expiry.

Use an actual attachment for documents such as a fixed terms PDF, packing slip or product manual that must arrive with a particular email. WooCommerce does not offer a general core setting for attaching arbitrary files to every order email.

Use the manual code route

For one fixed file on one standard customer email, add a small PHP snippet with a snippets plugin or a child theme. WooCommerce passes the attachment list, email ID, order and email object through the woocommerce_email_attachments filter.

add_filter( 'woocommerce_email_attachments', 'my_woocommerce_email_attachments', 10, 4 ); function my_woocommerce_email_attachments( $attachments, $email_id, $order, $email ) { if ( 'customer_completed_order' === $email_id ) { $attachments[] = '/absolute/path/to/file.pdf'; } return $attachments; }

Replace the placeholder with the file's absolute server path, not its web URL. For a processing-order message, use the confirmed email ID for that message instead of copying the completed-order ID. The filter and four-argument pattern are commonly used for this task.

Limit which emails receive it

Do not attach the file without checking the email ID. Otherwise the same document may be added to admin notifications, customer messages and manual resend emails. Keep the condition inside the filter and target only the customer email that needs the document.

The standard WooCommerce email settings are under WooCommerce → Settings → Emails. Those settings control each email's recipients, subject, heading and content, but an attachment normally comes from an extension or custom code rather than the standard email editor.

Handle product-specific files properly

If each product, category or order status needs a different PDF, the manual snippet becomes custom development. It must inspect the order's line items, find the related files, convert selected media references into server paths and avoid attaching duplicates when several products use the same document.

This is also where stores commonly break: a file URL is supplied where the mailer needs a local path, the code runs before a generated PDF exists, or a file is attached to every email instead of the intended status. For product attachments, use an extension that can assign files to products or categories and include them in order emails.

Test the exact customer email

Place a low-value test order using the same product and payment method as a real customer. Trigger the exact status that should send the message, then confirm the attachment opens and has the expected filename, size and contents.

Also test an order that should not receive the file. If the email fails or arrives without its attachment, check that the path exists on the server, the web server can read the file, the email ID matches the message being sent and your mail service permits the attachment size. Large files are often better delivered as protected download links.

Use a plugin for the fast way

For a non-technical setup, install and activate WooCommerce Email Attachments, then configure the attachment rules from its settings. This is the quicker route when you need several file types, multiple attachments, product or category rules, order-status conditions or limits without maintaining PHP code.

WooCommerce extensions that handle attachments generally provide an email selector and an upload or media-library control. For example, the WooCommerce Email Attachments documentation describes selecting registered WooCommerce emails and assigning uploaded files to them.

The fast route

Let WooCommerce Email Attachments do it

Adds product- and order-specific PDFs, images, and documents to WooCommerce emails when customers need purchase files.

Get WooCommerce Email Attachments

Sources

  1. woocommerce.com /document/digital-downloadable-product-handling/?utm_source=…
  2. wordpress.org /support/topic/send-an-attachment-with-order-confirmation-em…
  3. woocommerce.com /document/configuring-woocommerce-settings/emails/?utm_sourc…
  4. woocommerce.com /document/product-attachments-pro/?utm_source=openai
  5. woocommerce.com /document/email-attachments/?utm_source=openai
  6. woocommerce.com /document/email-faq/?utm_source=openai

Questions

Can WooCommerce attach files without a plugin?
Yes, WooCommerce can attach a fixed local file with custom PHP using the `woocommerce_email_attachments` filter. The snippet must target the correct email ID and use an absolute server path. WooCommerce's normal email settings do not provide a general upload field for arbitrary attachments, so product-specific rules still require custom development or an extension.
Can I attach a different file for each product?
Yes, but not with a simple fixed-file snippet. Custom code must inspect the order line items, identify each product's file and add the matching server paths to the email. A product-attachment extension is usually more practical because it can assign files to products or categories and include them in selected order emails.
What is the difference between an attachment and a downloadable product?
An attachment is included directly in the email as a file. A downloadable WooCommerce product normally gives the customer a protected download link in the order email and, for logged-in customers, under My account → Downloads. Use downloadable products when access control, expiry or download limits matter.
Why does the attachment work in one email but not another?
The code usually checks an email ID, and each WooCommerce notification has its own ID. A condition written for the completed-order email will not automatically affect processing, on-hold or customer-note emails. Check the exact notification being sent, then update the condition and test that status rather than assuming all order emails share one trigger.
Why did the email stop sending after I added an attachment?
The most common causes are an incorrect server path, unreadable file permissions, a missing file, an oversized attachment or a snippet syntax error. Remove or disable the snippet first to confirm the cause, then check the WooCommerce email log and mail-service limits. For large documents, replace the attachment with a protected download link.