mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://wordpress.stackexchange.com/questions/336146/set-a-condition-based-on-woocommerce-checkout-city-field-while-placing-order/
20 lines
610 B
Text
20 lines
610 B
Text
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_state();
|
|
$city = empty( $state ) ? $order->get_billing_city() : $tate;
|
|
|
|
// Conditionaly send additional email based on customer state
|
|
if ( 'Florida' == $state )
|
|
{
|
|
$recipient .= ',someemail@gmail.com';
|
|
}
|
|
elseif ( 'Texas' == $state )
|
|
{
|
|
$recipient .= ',differentemail@gmail.com';
|
|
}
|
|
|
|
return $recipient;
|
|
}
|