admin管理员组文章数量:1023078
How to make condition on WooCommerce checkout field like when user select city "Indore" then on place order email goes to [email protected]
and when he select "Bhopal" city then email goes to [email protected]
.
How to make condition on WooCommerce checkout field like when user select city "Indore" then on place order email goes to [email protected]
and when he select "Bhopal" city then email goes to [email protected]
.
1 Answer
Reset to default 1Updated
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.
How to make condition on WooCommerce checkout field like when user select city "Indore" then on place order email goes to [email protected]
and when he select "Bhopal" city then email goes to [email protected]
.
How to make condition on WooCommerce checkout field like when user select city "Indore" then on place order email goes to [email protected]
and when he select "Bhopal" city then email goes to [email protected]
.
1 Answer
Reset to default 1Updated
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.
本文标签: phpSet a condition based on WooCommerce checkout city field while placing order
版权声明:本文标题:php - Set a condition based on WooCommerce checkout city field while placing order 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745550000a2155585.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论