简体   繁体   English

Woocommerce-仅当管理员是收件人或按订单状态时,密件抄送电子邮件

[英]Woocommerce - Bcc email only when the admin is recipient OR by Order Status

How to Get email recipient to make an conditional function to add extra bcc email header on email only to admin OR by Order Status? 如何使电子邮件收件人具有条件功能,以便仅在电子邮件上向管理员或按订单状态添加额外的密件抄送电子邮件标头?

add_filter( 'woocommerce_email_headers', 'profit_extra_email', 10, 2);
function profit_extra_email( $headers ) {
    $headers .= 'BCC: Vendas Promocional Fitness <eu@site.com>' . "\r\n";
    return $headers;
}

This function above work, but bcc email retrieve all emails. 此功能可以正常工作,但密件抄送电子邮件会检索所有电子邮件。 I need retrieve only emails to admin OR by Order Status. 我只需要检索发送给管理员或按订单状态发送的电子邮件。

Help any!! 帮助任何人! :O :O

There are 3 variables passed to the woocommerce_email_headers filter. 有3个变量传递给woocommerce_email_headers过滤器。 Since none of them appear to be the $in_admin variable that is passed to templates, we have to take a different approach. 由于它们似乎都不是传递给模板的$in_admin变量,因此我们必须采用其他方法。 The second param is $email_id which is a unique identifier for each email class. 第二个参数是$email_id ,它是每个电子邮件类别的唯一标识符。 Therefore we can make an array of all the admin emails and check if the current email is in that array. 因此,我们可以对所有管理员电子邮件进行排列,并检查当前电子邮件是否在该阵列中。 If so, add your CC. 如果是这样,请添加您的抄送。

function so_31737121_email_headers( $headers, $email_id, $order ){
    $admin_emails = array( 
        'low_stock',
        'no_stock',
        'backorder',
        'cancelled_order',
        'new_order'
    );

    if( in_array( $email_id, $admin_emails ) ){
        $headers .= 'BCC: Vendas Promocional Fitness <eu@site.com>' . "\r\n";
    }
    return $headers;
}
add_action( 'woocommerce_email_headers', 'so_31737121_email_headers', 10, 3 );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Woocommerce BCC订购电子邮件给管理员 - Woocommerce BCC on order email to admin WooCommerce-根据产品类别更改订单状态和管理员电子邮件收件人 - WooCommerce - Change order status and admin e-mail recipient according to product category WooCommerce 向管理员发送 email 通知以获取特定订单状态 - WooCommerce send email notification to admin for specific order status 向管理员发送电子邮件通知以了解 WooCommerce 中的待定订单状态 - Send an Email notification to the admin for pending order status in WooCommerce WooCommerce - 如果使用某种运输方式,我如何才能停止将新订单 email 发送给管理员收件人? - WooCommerce - How can I stop the New Order email being sent to admin recipient if a certain shipping method is used? 在Woocommerce中以编程方式替换新订单电子邮件收件人 - Replace New order email recipient programmatically In Woocommerce 将管理员 email 设置为 WooCommerce 取消和失败订单的 BCC - Set admin email as BCC for WooCommerce cancelled and failed orders 在Woocommerce中将新帐户电子邮件通知作为密件抄送发送给管理员 - New Account Email Notification sent to Admin as BCC in Woocommerce 当管理员更新订单状态 woocommerce 时触发 function - trigger function when admin updates order status woocommerce 将WooCommerce处理订单电子邮件通知收件人更改为自定义地址 - Change WooCommerce processing order email notification recipient to a custom address
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM