[英]Add email recipients to New order notification for Local pickup in Woocommerce
I need to add an additional email address to new order notifications for 'local pickup' shipping method only.我只需要为“本地取件”运输方式的新订单通知添加一个额外的电子邮件地址。 So my staff can be notified immediately via those additional email address for new orders when the customer has chosen "Local pickup" from the shipping options.
因此,当客户从运输选项中选择“本地取货”时,我的员工可以立即通过这些额外的电子邮件地址收到新订单的通知。
How to add email recipients to New order notification for Local pickup in Woocommerce?如何将电子邮件收件人添加到 Woocommerce 中本地取货的新订单通知?
With this simple hooked function, you will be able to add additional recipients when "Local pickup" is the Order chosen shipping method for "New Order" email notification: 使用此简单的挂钩函数,当“本地取货”是“新订单”电子邮件通知的订单选择运送方式时,您将能够添加其他收件人:
add_filter( 'woocommerce_email_recipient_new_order', 'additional_email_recipient', 10, 2 );
function additional_email_recipient( $recipient, $order ) {
if ( ! is_a( $order, 'WC_Order' ) ) return $recipient;
// The shipping method name to target
if( $order->get_shipping_method() == 'Local pickup' ){
// Add your recipients coma separated in a unique string
$recipient .= ',name.one@domain.com,name.two@omain.com';
}
return $recipient;
}
Code goes in function.php file of the active child theme (or active theme). 代码进入活动子主题(或活动主题)的function.php文件中。
Tested and works (Re tested 2 times). 经过测试并可以工作(重新测试2次)。
You will have to be sure that "Local pickup" is the shipping label name.
您必须确保“本地取件”是运输标签名称。
I tweaked the above code and it now works.我调整了上面的代码,现在可以工作了。
//Add new email to receive notification when local_pickup is chosen as shipping method
add_filter( 'woocommerce_email_recipient_new_order', 'additional_email_recipient', 10, 2 );
function additional_email_recipient( $recipient, $order ) {
if ( ! is_a( $order, 'WC_Order' ) ) return $recipient;
// The shipping method name to target
if( $order->has_shipping_method('local_pickup') ){
// Add your recipients comma separated in a unique string
$recipient .= ',you@yourcompany.com';
}
return $recipient;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.