You can use a plugin like WooCommerce PDF Invoices & Packing Slips to automatically attach invoices to customer emails, or add custom code with WooCommerce hooks.
If you’re running an ecommerce store, sending invoices manually is a waste of time. This guide shows you how to automatically email invoices in WooCommerce — with professionally branded PDFs attached to every order email. Whether you’re selling B2B, physical goods, or digital products, this workflow is a must.
We’ll cover:
- ✅ How to send automatic PDF invoices on order complete
- ✅ How to customize the invoice design with your logo & layout
- ✅ Code-free and developer-level options
- ✅ Bonus: Attach invoice to customer note and admin emails
Why Send Automatic Invoice Emails in WooCommerce?
- 🧾 Legal and tax compliance for B2B and international orders
- 📩 Improved professionalism and customer trust
- ⏱️ Saves time vs manually generating invoices
- 🖨️ Easy PDF download for record keeping
Option 1: Use a Plugin (No Code Required)
🛠 Recommended Plugin: WooCommerce PDF Invoices & Packing Slips
This plugin automatically generates and attaches a PDF invoice to the customer’s order email. It also allows for invoice numbering, logo upload, footer notes, and more.
✅ Setup Instructions:
- Install the plugin from Plugins → Add New → Search “PDF Invoices”
- Go to WooCommerce → PDF Invoices
- Upload your logo and adjust company details
- Set which email(s) to attach the PDF (Order Completed, Customer Invoice, etc.)
🧠 Bonus:
Upgrade to their Professional extension to:
- Change layout with drag-and-drop designer
- Attach custom terms & conditions
- Send credit notes or proforma invoices
Option 2: Programmatic Method Using WooCommerce Hooks (Dev Level)
Want to control how invoices are created or emailed? You can hook into order actions and attach your own PDFs.
🧩 Hook into the Completed Order Email
add_filter('woocommerce_email_attachments', 'attach_custom_invoice_pdf', 10, 3);
function attach_custom_invoice_pdf($attachments, $email_id, $order) {
if ($email_id === 'customer_completed_order') {
$upload_dir = wp_upload_dir();
$pdf_path = $upload_dir['basedir'] . '/invoices/invoice-' . $order->get_id() . '.pdf';
if (file_exists($pdf_path)) {
$attachments[] = $pdf_path;
}
}
return $attachments;
}
This checks if a PDF exists for the order and attaches it to the email. You’d need a custom function elsewhere to generate and save the PDF.
📄 How to Generate the PDF?
Use libraries like mPDF or DOMPDF to create invoice PDFs dynamically. Here’s a sample of how to create a basic one:
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf();
$order = wc_get_order($order_id);
$html = '<h1>Invoice #' . $order->get_id() . '</h1>';
$html .= '<p>Customer: ' . $order->get_billing_first_name() . '</p>';
$mpdf->WriteHTML($html);
$upload_dir = wp_upload_dir();
$mpdf->Output($upload_dir['basedir'] . '/invoices/invoice-' . $order->get_id() . '.pdf', \Mpdf\Output\Destination::FILE);
Trigger this after order status is marked as “completed” using:
add_action('woocommerce_order_status_completed', 'generate_invoice_pdf');
function generate_invoice_pdf($order_id) {
// Your custom PDF generation logic goes here
}
Customizing the Invoice Design
If you’re using the plugin, go to PDF Invoices → Templates and:
- ✅ Upload your company logo
- ✅ Adjust header, footer, and font sizes
- ✅ Include legal or tax info like VAT or EIN numbers
If you’re using your own PDF library, you can fully style the PDF with HTML/CSS inside the WriteHTML() method.
Sending Invoices on Different Email Types
You can attach invoices to multiple WooCommerce email types using the same woocommerce_email_attachments
filter. Just check for:
customer_invoice
customer_processing_order
new_order
(admin notification)
Final Thoughts
Automatically emailing WooCommerce PDF invoices boosts your professionalism and ensures customers always have the documents they need — without lifting a finger.
Whether you use a no-code plugin or code it from scratch with mPDF or DOMPDF, you’ll end up with a fast, scalable solution that saves time and enhances your brand.
Need help building a custom PDF invoice engine or automating your order flows? Contact Babar Ilyas for custom WooCommerce automation & dev work.
Looking to go deeper? Check out our guide on automating abandoned cart emails or learn to add dynamic checkout fees.