• Resolved darkallman

    (@darkallman)


    What I am looking for is a way to send the invoice to a second different email address.
    Where I can let the user, setup a second email address to where the invoices are sent. We have several b2b customers who would like the invoice sent directly to their finance departments.
    Is this possible?

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

    (@pomegranate)

    Hi!
    You could add an extra checkout field for this purpose using one of the many WooCommerce Checkout field editor plugins. You can then use a filter to add this address as CC to the email sent to the customer, following this guide. Here’s an example that does this for the Completed order email.

    
    add_filter( 'woocommerce_email_headers', 'wpo_wcpdf_invoice_second_email', 10, 3 );
    function wpo_wcpdf_invoice_second_email( $headers, $email_id, $object ) {
        if ($email_id == 'customer_completed_order') {
            // enter the name of the custom field in which the second email address is stored in place of 'xxx'
            $email_address = $object->get_meta('xxx');
            if (!empty($email_address)) {
                $headers .= sprintf( "CC: %s \r\n", $email_address );
            }
        }
        return $headers;
    }
    

    If you’re not sure which field name to sue in the above code (instead of ‘xxx’), check this guide: Finding WooCommerce Custom Fields

    Hope that helps!

    Thread Starter darkallman

    (@darkallman)

    This is excellent work! case closed!

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

The topic ‘Invoice email address’ is closed to new replies.