Custom “reply to” email header in Woocommerce New Order email notification

前端 未结 1 625
陌清茗
陌清茗 2021-01-13 15:06

I\'m looking to filter the email headers of the new order form in woocommerce. I\'m trying to replace the customer email address with the main site admin email address. We n

相关标签:
1条回答
  • 2021-01-13 15:21

    The correct way to make it work is:

    add_filter( 'woocommerce_email_headers', 'new_order_reply_to_admin_header', 20, 3 );
    function new_order_reply_to_admin_header( $header, $email_id, $order ) {
    
        if ( $email_id === 'new_order' ){
            $email = new WC_Email($email_id);
            $header = "Content-Type: " . $email->get_content_type() . "\r\n";
            $header .= 'Reply-to: ' . __('Administrator') . ' <' . get_option( 'admin_email' ) . ">\r\n";
        }
        return $header;
    }
    

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

    0 讨论(0)
提交回复
热议问题