Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change "reply to" email address in all Woocommerce emails notifications

In Woocommerce, I would like to change the email address that should always be used as the reply address for all emails notifications.

How is this possible with Woocommerce?

like image 708
Maurice Von Ellm Avatar asked Dec 23 '22 00:12

Maurice Von Ellm


1 Answers

The following will change the "Reply to" email address (and name) in all email notifications:

add_filter( 'woocommerce_email_headers', 'change_reply_to_email_address', 10, 3 );
function change_reply_to_email_address( $header, $email_id, $order ) {

    // HERE below set the name and the email address
    $reply_to_name  = 'Jack Smith';
    $reply_to_email = '[email protected]';

    // Get the WC_Email instance Object
    $email = new WC_Email($email_id);

    $header  = "Content-Type: " . $email->get_content_type() . "\r\n";
    $header .= 'Reply-to: ' . $reply_to_name . ' <' . $reply_to_email . ">\r\n";

    return $header;
}

This code goes on function.php file of your active child theme (or theme). Tested and works (Thanks to helgatheviking).

Related: Custom "reply to" email header in Woocommerce New Order email notification


Note (update): Since WooCommerce 3.7, the WC_Email instance Object is now included in the hook as 4th argument.

like image 74
LoicTheAztec Avatar answered Mar 26 '23 14:03

LoicTheAztec