日安!我希望禁用Woocommerce的新订单通知,从其他平台同步的订单,因为他们已经自动标记为完成。目前,我正在收到来自所有导入订单的新订单通知。这些订单有自己的自定义字段。
是否可以使用钩子来编写自定义代码,以防止向管理员发送带有ced_shopee_order_shop_id或ced_lazada_seller_id属性的订单的新订单通知电子邮件?
我仍然希望在我的网站上收到订单的电子邮件通知。
任何帮助都将不胜感激!
目前,我已经修改了Víctor Calderón给出的代码,但它不适用于我的情况。
add_filter('woocommerce_email_recipient_new_order', 'disable_notification_based_on_id', 10, 2);
function disable_notification_based_on_id($recipient, $order) {
$page = $_GET['page'] = isset($_GET['page']) ? $_GET['page'] : '';
if ('wc-settings' === $page) {
return $recipient;
}
if (!$order instanceof WC_Order) {
return $recipient;
}
$items = $order -> get_items();
foreach($items as $item) {
$shopee_id = $item['ced_shopee_order_shop_id'];
$lazada_id = $item['ced_lazada_seller_id'];
if ($shopee_id == 377700604 || $lazada_id == 1143399005) {
$recipient = '';
}
return $recipient;
}
}
发布于 2021-09-21 12:30:14
我使用了以下代码来禁用基于产品id的通知(在我的示例中是产品id 5274),因此您应该尝试使用与您的值匹配的ced_shopee_order_shop_id或ced_lazada_seller_id来更改$item' product _id‘
add_filter('woocommerce_email_recipient_new_order', 'disable_notification_based_on_id', 10, 2);
function disable_notification_based_on_id($recipient, $order)
{
$page = $_GET['page'] = isset($_GET['page']) ? $_GET['page'] : '';
if ('wc-settings' === $page) {
return $recipient;
}
if (!$order instanceof WC_Order) {
return $recipient;
}
//this is the example for product id==5274, change the value to your atribute
$items = $order->get_items();
foreach ($items as $item) {
$product_id = $item['product_id'];// change to your atribute ced_shopee_order_shop_id OR ced_lazada_seller_id
if ($product_id == 5274) {
$recipient = '';
}//change if condition to match your ced_shopee_order_shop_id OR ced_lazada_seller_id value
return $recipient;
}
}
https://stackoverflow.com/questions/69258442
复制相似问题