Skip to main content
added 94 characters in body
Source Link
LoicTheAztec
  • 3.4k
  • 17
  • 24

Updated

The following code will add an additional recipient based on customer billing/shipping city, to new order admin notification:

add_filter( 'woocommerce_email_recipient_new_order', 'different_email_recipients', 10, 2 );
function different_email_recipients( $recipient, $order ) {
    if ( ! is_a( $order, 'WC_Order' ) ) 
        return $recipient;

    $city = $order->get_shipping_city();
    $city = empty( $city ) ? $order->get_billing_city() : $city;

    // Conditionaly send additional email based on customer city
    if ( in_array( 'Indore', $country_fields== )$city ) 
    {
        $recipient .= ',[email protected]';
    } 
    elseif ( in_array('bhopal', $country_fields== )$city ) 
    {
        $recipient .= ',[email protected]';
    }

    return $recipient;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

The following code will add an additional recipient based on customer billing/shipping city, to new order admin notification:

add_filter( 'woocommerce_email_recipient_new_order', 'different_email_recipients', 10, 2 );
function different_email_recipients( $recipient, $order ) {
    if ( ! is_a( $order, 'WC_Order' ) ) 
        return $recipient;

    // Conditionaly send additional email based on customer city
    if ( in_array( 'Indore', $country_fields ) ) 
    {
        $recipient .= ',[email protected]';
    } 
    elseif ( in_array('bhopal', $country_fields ) ) 
    {
        $recipient .= ',[email protected]';
    }

    return $recipient;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

Updated

The following code will add an additional recipient based on customer billing/shipping city, to new order admin notification:

add_filter( 'woocommerce_email_recipient_new_order', 'different_email_recipients', 10, 2 );
function different_email_recipients( $recipient, $order ) {
    if ( ! is_a( $order, 'WC_Order' ) ) 
        return $recipient;

    $city = $order->get_shipping_city();
    $city = empty( $city ) ? $order->get_billing_city() : $city;

    // Conditionaly send additional email based on customer city
    if ( 'Indore' == $city ) 
    {
        $recipient .= ',[email protected]';
    } 
    elseif ( 'bhopal' == $city ) 
    {
        $recipient .= ',[email protected]';
    }

    return $recipient;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

Source Link
LoicTheAztec
  • 3.4k
  • 17
  • 24

The following code will add an additional recipient based on customer billing/shipping city, to new order admin notification:

add_filter( 'woocommerce_email_recipient_new_order', 'different_email_recipients', 10, 2 );
function different_email_recipients( $recipient, $order ) {
    if ( ! is_a( $order, 'WC_Order' ) ) 
        return $recipient;

    // Conditionaly send additional email based on customer city
    if ( in_array( 'Indore', $country_fields ) ) 
    {
        $recipient .= ',[email protected]';
    } 
    elseif ( in_array('bhopal', $country_fields ) ) 
    {
        $recipient .= ',[email protected]';
    }

    return $recipient;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.