繁体   English   中英

WooCommerce完成订单上的其他电子邮件

[英]WooCommerce additional email on completed order

我有一个问题,需要社区支持,因为我在网上找不到任何东西,包括WooCommerce支持论坛。

我有一个WooCommerce网站,这是一家本地连锁餐馆使用的封闭式电子商务商店。 每次存储订单时,GM都会希望收到一封已完成订单的电子邮件,因此他可以阻止或批准该订单。 GM1负责Store1,Store2和Store3; GM2负责Store4,Store5和Store 6等。

借助互联网,到目前为止,这是我在function.php中拥有的内容。 功能正常运行并被触发,但是所有3个GM都收到电子邮件,但从理论上讲,只有一个GM应该收到电子邮件。 商店1或商店2或商店3的GM1; 如果Store4或Store5或Store6订单,GM2和GM2应该会收到电子邮件。

如果有人可以将我指向正确的方向,或者至少让我知道为什么所有三个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;
}

谢谢。

我最终使用如下所示的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM