• Resolved Joost1981

    (@joost1981)


    Since talking in ordernumbers and invoicenumbers can be confusing for our customers I edited the woocommerce email templates (copy to child theme) so this will display the invoice number instead of the ordernumber:

    $order->get_meta( ‘_wcpdf_invoice_number’ )

    When the order has status ‘Processing’ and the first e-mail is sent to the customer the Invoice Number is not yet generated and empty. This results in an customer-processing-order e-mail with an attached invoice PDF but with an empty invoice number in the HTML e-mail.

    How can I change the order of generation that the Invoice number is generated on save time of the order?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! This is due to the order in which WooCommerce generates parts of the email. The attachments are generated much later than the email body, so when an email does not have an invoice yet before sending the email, it will not find the invoice number. You can fix this with a single line before your get_meta():

    
    $invoice = wcpdf_get_invoice( $order, true );
    

    you can then even avoid the extra meta call because the number is already in the invoice object:

    
    $invoice_number = $invoice->get_number()->get_formatted();
    
    Thread Starter Joost1981

    (@joost1981)

    Great! Thank you Ewout. I’ve put this in the ’email-order-details.php’ template.

    Have a nice weekend!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Invoice number empty when sending e-mail’ is closed to new replies.