php - 如何向管理员和客户发送暂停的 WooCommerce 电子邮件通知
问题描述
默认情况下,WooCommerce 仅向客户发送 On-Hold 订单通知(不知道为什么,因为似乎让商店经理知道订单何时被搁置非常重要......)
我已经尝试根据我在这里和谷歌上发现的研究线程在我的子主题的functions.php中实现以下片段:向管理员发送暂停订单状态电子邮件通知
add_filter( 'woocommerce_email_headers', 'custom_admin_email_notification', 10, 3);
function custom_admin_email_notification( $headers, $email_id, $order ) {
if( 'customer_on-hold_order' == $email_id ){
// Set HERE the Admin email
$headers .= 'Bcc: My name <my@email.com>\r\n';
}
return $headers;
}
我还尝试了来自同一线程的以下代码段:
// Send on-hold order status email notification to admin
add_filter( 'woocommerce_email_headers', 'custom_admin_email_notification', 10, 3);
function custom_admin_email_notification( $headers, $email_id, $order ) {
if( strpos($email_id,'hold') > 0 ){
$headers .= 'Bcc: Admin User <admin@example.com>'. "\r\n";
}
return $headers;
}
当订单从待付款更改为暂停时,这些似乎都不起作用。是的,我已将片段中的电子邮件更改为我的管理员电子邮件。我正在寻找一种解决方案,当这种情况自动发生(从待付款到暂停)或在编辑订单时手动发生时,管理员将在客户暂停电子邮件中被密件抄送。
解决方案
- 添加utf8_decode可能会有所帮助
- 替换
customer_on-hold_order
为customer_on_hold_order
- 使用 Wordpress 5.8.1 和 WooCommerce 5.6.0 测试
所以你得到:
function filter_woocommerce_email_headers( $header, $email_id, $order ) {
// Compare
if ( $email_id == 'customer_on_hold_order' ) {
// Prepare the the data
$formatted_email = utf8_decode( 'My test <my_test@email.com>' );
// Add Bcc to headers
$header .= 'Bcc: ' . $formatted_email . '\r\n';
}
return $header;
}
add_filter( 'woocommerce_email_headers', 'filter_woocommerce_email_headers', 10, 3 );
推荐阅读
- android - 如何传输通话记录数据?
- python - 如何批量输入训练有素的 Python TensorFlow 模型?
- node.js - NodeJS如何制作一个特殊的get CRUD
- python - 仅考虑预测>阈值的混淆矩阵
- oracle - 我怎样才能删除这个..plz告诉我,因为我尝试了everyting。这段代码中是否有任何问题
- reactjs - 如何在反应中调用onPress下的两个函数
- flutter - 使用 AnnotatedRegion 后如何将状态栏恢复为默认值?
- c++ - 消息的当前实例在 MFC 中完成后如何发布消息?
- python - Python Tweepy 基于 Geocode 获取所有推文
- regex - 没有左边界或右边界的值的 Jmeter 相关性