Invoice number in e-mail subject
-
Hi,
I would like to have the invoice number in the subject of the PDF invoice e-mail send to the customer is this possible?
-
Hi @basvweb,
Sure! This is possible by adding this code snippet to your site:
/** * Add the {invoice_number} placeholder to the WC email notifications */ add_filter( 'woocommerce_email_format_string' , 'wpo_wcpdf_email_placeholders', 20, 2 ); function wpo_wcpdf_email_placeholders( $string, $email ) { if ( strpos( $string, '{invoice_number}' ) !== false && !empty($email->object) && $invoice = wcpdf_get_invoice( $email->object, true ) ) { return str_replace( '{invoice_number}', $invoice->get_number()->get_formatted(), $string ); } return $string; }After that, you can use the
{invoice_number}placeholder to display the invoice number as the subject of your WooCommerce notifications.Let me know if it worked 🙂
Great!! Thank you so much, it works!
I’m glad to know it!
If you don’t mind and have the time, do you think you could leave us a review?
Thanks in advance and all the best with your store!
Hi @yordansoares ,
I will!
Is it possible to be able to use the {invoice_number} also in other WooCommerce emails, maybe in the subject or in the email text.
Yes, you can the placeholder in the subject, email heading, and additional content.
Note that if the order doesn’t have an invoice created yet, the email triggering will generate one to be able to replace the placeholder with the actual invoice. So, my recommendation is to use the {invoice_number} placeholder just in those order email notification in which you have receive the payment, often Processing order and Completed order.
When I get the email the subject does show the correct invoice number but in the additional content it shows the following:
Thank you very much for your order. Please find your invoice {invoice_number} for order S1642 attached. Please note that payment is by wire transfer only.
Hi @basvweb,
This is strange. I just tested again, and I got the invoice number in every place.
If you typed the placeholder, could you try copying and pasting it instead? Perhaps this was caused by a typing error.
Hi @basvweb,
This screenshot appears not to be from an actual email notification, but from an email customizer. You need to send a test email if you want to see the actual email output.
To do so, you can create a new test order or resend specific email notifications for an existent order from the Send order email panel, within the single order editing screen:

Hi @yordansoares ,
Here: https://ibb.co/pz2SKKm
Here is a better one: @yordansoares
Hi @basvweb,
The
{invoice_number}is intended to be used in the editing screen of the WooCommerce email notifications (WooCommerce > Settings > Emails). If you’re using a custom email template or a WooCommerce email customizer plugin, you need to find out how to include placeholders there.Hope it helps!
Hi @yordansoares ,
So it is not possible to show the invoice number in the email content?
The topic ‘Invoice number in e-mail subject’ is closed to new replies.