【发布时间】:2017-06-07 13:56:52
【问题描述】:
我有一个问题需要社区支持,因为我在网络上找不到任何东西,包括 WooCommerce 支持论坛。
我有一个 WooCommerce 网站,这是一家本地连锁餐厅使用的封闭式电子商务商店。每次商店订购任何东西时,GM 还希望在完成订单时向他发送一封电子邮件,以便他可以阻止订单或批准订单。 GM1负责Store1、Store2和Store3; GM2负责Store4、Store5、Store 6等。
在互联网的帮助下,这就是我目前在 function.php 中所拥有的。功能正常工作并被触发,但所有 3 名 GM 都收到了电子邮件,但理论上,只有一名 GM 应该收到电子邮件。 GM1 用于 Store1 OR Store2 OR Store3;如果 Store4 OR Store5 OR Store6 订单,GM2 应该会收到电子邮件。
如果有人能指出正确的方向或至少让我知道为什么所有三个 if 都会被触发,我真的很感激。
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;
}
谢谢。
【问题讨论】:
-
您是否正在使用任何供应商插件?
-
查看 PHP 控制结构文档 (php.net/manual/en/control-structures.elseif.php),应该是
if和elseif。 -
不,不使用任何供应商插件。我也试过 if{} elseif{},但结果还是一样。所有 3 位 GM 都收到了电子邮件。
标签: php wordpress woocommerce orders email-notifications