• Resolved basvweb

    (@basvweb)


    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?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    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 ??

    Thread Starter basvweb

    (@basvweb)

    Great!! Thank you so much, it works!

    Plugin Contributor Yordan Soares

    (@yordansoares)

    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!

    Thread Starter basvweb

    (@basvweb)

    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.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    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.

    Thread Starter basvweb

    (@basvweb)

    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.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    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.

    Thread Starter basvweb

    (@basvweb)

    Hi @yordansoares ,

    I have added a screenshot:

    https://ibb.co/S5vSW77

    Plugin Contributor Yordan Soares

    (@yordansoares)

    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:

    A animated screenshot that display the Send order email in action

    Thread Starter basvweb

    (@basvweb)

    Thread Starter basvweb

    (@basvweb)

    Here is a better one: @yordansoares

    https://ibb.co/rG1zrr6

    Plugin Contributor Yordan Soares

    (@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!

    Thread Starter basvweb

    (@basvweb)

    Hi @yordansoares ,

    So it is not possible to show the invoice number in the email content?

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Invoice number in e-mail subject’ is closed to new replies.