• Resolved marijn1887

    (@marijn1887)


    Hi,

    Great plugin, thanks!

    I created a custom field for a second customer email adress. Now I need that second email adress to also receive the invoice as well as the standard customer email adress.

    I found this code but get a fatal error (might conflict with another plugin):

    add_filter( 'woocommerce_email_headers', 'wcpdf_email_cc_alternative', 10, 3);
    
    function wcpdf_email_cc_alternative( $headers, $email_id, $order ) {
    	if ($email_id == 'customer_completed_order') {
    		$alternative_email = get_post_meta( $order->id, '_alternative_email_field', true)
    		if ( $alternative_email ) {
    			$headers .= 'CC: ' . $alternative_email . "\r\n"; //just repeat this line again to insert another email address in BCC
    		}
    	}
    
    	return $headers;
    }

    Does this code needs to be updated? Or it it still the right way?
    FYI I changed “_alternative_email_field” with my custom field name.

    Thanks in advance

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

    (@pomegranate)

    it’s a missing semi-colon at the end of this line:

    
    $alternative_email = get_post_meta( $order->id, '_alternative_email_field', true );
    

    For WooCommerce 3.0 however, the use of get_post_meta is deprecated. Instead, use:

    
    $alternative_email = $order->get_meta( '_alternative_email_field', true );
    
    Thread Starter marijn1887

    (@marijn1887)

    Thanks so much, Ewout! Works Great!

    Plugin Contributor Ewout

    (@pomegranate)

    You’re welcome! If you have time for a plugin review, I’d really appreciate that!

    Thanks in advance!
    Ewout

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add Custom Field [Email adress] for second recipient invoice’ is closed to new replies.