Attaching invoice to third-party\custom emails

Since 3.2.1 version 2 filters were added that allows adding invoices to some other emails.

 // Allow developers to override
$send_regular = apply_filters('woo_pdf_email_send_regular_invoice', $send_regular, $order_id, $email_type);
$send_proforma = apply_filters('woo_pdf_email_send_proforma_invoice', $send_proforma, $order_id, $email_type);

For example, we could add this to the completed order email sent by WooCommerce Subscriptions plugin:

add_filter('woo_pdf_email_send_regular_invoice', 'woo_pdf_email_send_regular_invoice_change', 10, 3);
function woo_pdf_email_send_regular_invoice_change($send, $order_id, $email_type) {

if ($email_type === 'customer_completed_renewal_order') {
return true;
}

return $send;

 As you can see, just need to know the correct email_type - the id each email has. In this case the value is "customer_completed_renewal_order".

Have more questions? Submit a request