[英]WooCommerce additional email on completed order
I have a question, which need a community support as I couldn't find anything on the web including WooCommerce support forum. 我有一个问题,需要社区支持,因为我在网上找不到任何东西,包括WooCommerce支持论坛。
I have a WooCommerce site which is a closed e-commerce store used by local chain of restaurants. 我有一个WooCommerce网站,这是一家本地连锁餐馆使用的封闭式电子商务商店。 Each time stores order anything, GM would also like a email sent to him on completed order, so he can either block the order or approve it.
每次存储订单时,GM都会希望收到一封已完成订单的电子邮件,因此他可以阻止或批准该订单。 GM1 is responsible for Store1, Store2 and Store3;
GM1负责Store1,Store2和Store3; GM2 is responsible for Store4, Store5, and Store 6 and so forth.
GM2负责Store4,Store5和Store 6等。
With the help of internet, this is what I have so far in function.php. 借助互联网,到目前为止,这是我在function.php中拥有的内容。 Function is working properly and getting triggered, but all 3 GMs are getting email, but in theory, only one GM should get email.
功能正常运行并被触发,但是所有3个GM都收到电子邮件,但从理论上讲,只有一个GM应该收到电子邮件。 GM1 for Store1 OR Store2 OR Store3;
商店1或商店2或商店3的GM1; and GM2 should get email if Store4 OR Store5 OR Store6 orders.
如果Store4或Store5或Store6订单,GM2和GM2应该会收到电子邮件。
Really appreciate if somebody can point me to the right direction or atleast let me know why all three ifs are getting triggered. 如果有人可以将我指向正确的方向,或者至少让我知道为什么所有三个ifs都被触发,我将非常感激。
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'your_email_recipient_filter_function', 10, 2);
function your_email_recipient_filter_function($recipient, $object) {
if( 'Store1@store.com' || 'Store2@store.com' || 'Store3@store.com' == $recipient ){
$recipient = $recipient .= ', GM1@store.com';
}
if( 'Store4@store.com' || 'Store5@store.com' || 'Store6@store.com' == $recipient ){
$recipient = $recipient .= ', GM2@store.com';
}
if( 'Store7@store.com' || 'Store8@store.com' || 'Store9@store.com' == $recipient ){
$recipient = $recipient .= ', GM3@store.com';
}
return $recipient;
}
Thanks. 谢谢。
I ended up using an array() as below which seems to be working: 我最终使用如下所示的array()似乎正在工作:
function your_email_recipient_filter_function( $recipient, $order ) {
$Stores1 = array('Store1@store.com', 'Store2@store.com', 'Store3@store.com');
$Stores2 = array('Store4@store.com', 'Store5@store.com', 'Store6@store.com');
$Stores3 = array('Store7@store.com', 'Store8@store.com', 'Store9@store.com');
$StoreEmail = $order->billing_email;
if ( in_array( $StoreEmail, $Stores1)) {
$recipient .= ', GM1@store.com';
} elseif ( in_array( $StoreEmail, $Stores2) ) {
$recipient .= ', GM2@store.com';
} elseif ( in_array( $StoreEmail, $Stores3) ) {
$recipient .= ', GM2@store.com';
}
return $recipient;
}
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'your_email_recipient_filter_function', 10, 2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.