Customizing email headers in WooCommerce email notifications

北城以北 提交于 2019-12-04 20:08:32

You have inverted the arguments in your function regarding woocommerce_email_headers filter hook (Note: I don't use WooCommerce Advanced Notifications plugin).

Instead try this (I have make some little changes):

add_filter( 'woocommerce_email_headers', 'custom_email_notification_headers', 10, 3 );
function custom_email_notification_headers( $headers, $email_id, $order ) {

    // Get the city
    $city = $order->get_billing_city();

    $headers = array( $headers );

    if ($city == 'Manchester')
    {
        $headers[] = 'Reply-to: Manchester <manchester@city.org>';
    }
    else
    {
        $headers[] = 'Reply-to: London <london@city.org>';
    }
    return $headers;
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

This code is tested on WooCommerce versions 3+ and works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!