Jonathan Perez
Jonathan Perez

Reputation: 73

remove "Reply-to: address" from new order woocommerce

some time ago when the customers made a new order, in the mail header the "reply-to" was not shown in the mail that came to me (as an admin), but now if, and I need to avoid showing it, I have tested with

add_filter( 'woocommerce_email_headers', 'add_reply_to_wc_admin_new_order', 10, 3 );

function add_reply_to_wc_admin_new_order( $headers = '', $id = '', $order ) {
    if ( $id == 'new_order' ) {
        $reply_to_email = $order->billing_email;
        $headers .= "Reply-to: <[email protected]>\r\n";
    }
    return $headers;
}

but the client's email keeps appearing in the reply-to, any idea? How to solve this?

Upvotes: 0

Views: 1135

Answers (1)

kashalo
kashalo

Reputation: 3562

here is your solution to keep only the header type without Reply to:

add_filter('woocommerce_email_headers', 'add_reply_to_wc_admin_new_order', 10, 3);

function add_reply_to_wc_admin_new_order($header = '', $id = '', $order)
{
    $wc_email = new WC_Email(); //instantiate wc meail

    if ($id == 'new_order') {
        $reply_to_email = $order->billing_email;
        $header = 'Content-Type: ' . $wc_email->get_content_type() . "\r\n"; 
    }

    return $header;
}

Upvotes: 2

Related Questions