【发布时间】:2019-06-16 05:13:20
【问题描述】:
对于 Woocommerce,如果购买了特定产品,我想将 woocommerce 新订单/处理订单/暂停订单电子邮件密送至其他多个电子邮件地址。
如果购买了特定产品,我当前的编码可以发送到指定的电子邮件。
但是,电子邮件是通过“收件人:”而不是“密件抄送:”发送的 并且显示了“回复”,我希望它也被删除/隐藏。
add_filter( 'woocommerce_email_recipient_new_order', 'conditional_recipient_new_email_notification', 15, 2 );
function conditional_recipient_new_email_notification( $recipient, $order ) {
if( is_admin() ) return $recipient; // (Mandatory to avoid backend errors)
// ## — YOUR SETTINGS (below) — ##
$targeted_id = 1111; // HERE define your targeted product ID
$addr_email = 'additional1@gmail.com, additional2@gmail.com'; // Here the additional recipient (If multiple, separate them by a coma)
// Loop through orders items
foreach ($order->get_items() as $item_id => $item ) {
if ( $item->get_variation_id() == $targeted_id || $item->get_product_id() == $targeted_id ) {
$recipient .= 'Bcc:' . ', ' . $addr_email . "\r\n";
break; // Found and added – We stop the loop
}
}
$targeted_id2 = 1821; // HERE define your targeted product ID
$addr_email2 = 'additional3@gmail.com, additional4@gmail.com'; // Here the additional recipient (If multiple, separate them by a coma)
// Loop through orders items
foreach ($order->get_items() as $item_id => $item ) {
if ( $item->get_variation_id() == $targeted_id2 || $item->get_product_id() == $targeted_id2 ) {
$recipient .= 'Bcc: ' . ', ' . $addr_email2 . "\r\n";
break; // Found and added – We stop the loop
}
}
return $recipient;
}
我怎样才能达到我想要的结果?
我想要密件抄送:而不是收件人: 并回复:被删除/隐藏。
【问题讨论】:
标签: php wordpress woocommerce