简体   繁体   English

更改特定WooCommerce电子邮件通知的发件人姓名和电子邮件地址

[英]Change sender name and email address for specific WooCommerce email notifications

How to change email sender address and name in WooCommerce for specific email notifications? 如何在WooCommerce中更改电子邮件发件人地址和姓名以获取特定的电子邮件通知?

For example: 例如:
Change the sender name and email address just for customer processing order email notifications. 仅为客户处理订单电子邮件通知更改发件人姓名和电子邮件地址。

But not for all email notifications, just for specific ones. 但不适用于所有电子邮件通知,仅针对特定电子邮件通

The sender name and email address are set here (at the end of Woocommerce "Emails" setting tab: 发件人姓名和电子邮件地址在此处设置(在Woocommerce“电子邮件”设置标签的末尾:

在此输入图像描述

This fields are passed through dedicated filters hook that allow you to change conditionally the values. 此字段通过专用过滤器钩子传递,允许您有条件地更改值。

Here is an example conditionally restricted to "customer processing email notification": 以下是有条件限制为“客户处理电子邮件通知”的示例:

// Change sender name
add_filter( 'woocommerce_email_from_name', function( $from_name, $wc_email ){
    if( $wc_email->id == 'customer_processing_order' ) 
        $from_name = 'Jack the Ripper';

    return $from_name;
}, 10, 2 );

// Change sender adress
add_filter( 'woocommerce_email_from_address', function( $from_email, $wc_email ){
    if( $wc_email->id == 'customer_processing_order' )
        $from_email = 'jack.the.ripper@freek.com';

    return $from_email;
}, 10, 2 );

Code goes in function.php file of your active child theme (or theme) or also in any plugin file. 代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中。

This code is tested and works. 此代码经过测试和运行。

Some other WC_Email Ids that you can use in your condition: - 'customer_completed_order' 您可以在条件中使用的其他一些WC_Email ID: - 'customer_completed_order'
- 'customer_on_hold_order' - 'customer_on_hold_order'
- 'customer_refunded_order' - 'customer_refunded_order'
- 'customer_new_account' - 'customer_new_account'
- 'new_order' ( admin notification ) - 'new_order' (管理员通知)
- 'cancelled_order' ( admin notification ) - 'cancelled_order' (管理员通知)
- 'failed_order' ( admin notification ) - 'failed_order' (管理员通知)

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

相关问题 在 WooCommerce email 通知中将发件人名称更改为客户账单全名 - Change sender name to customer billing full name in WooCommerce email notifications 更改 woocommerce 发件人电子邮件名称动态 - Change woocommerce sender email name dynamic 在Woocommerce中更改某些特定电子邮件通知的电子邮件主题 - Change email subjects for some specific email notifications in Woocommerce 将回复 email 地址更改为特定 WooCommerce email 通知 - Change reply-to email address to specific WooCommerce email notification 更改所有 Woocommerce 电子邮件通知中的“回复”电子邮件地址 - Change "reply to" email address in all Woocommerce emails notifications 从 Woocommerce 中的电子邮件通知更改下载部分中的列名称 - Change column name in Downloads section from email notifications in Woocommerce 始终在 WooCommerce 电子邮件通知中显示送货地址 - Always display shipping address in WooCommerce email notifications 将php形式的发件人电子邮件地址更改为收件人 - change sender email address in php form to recipient 在PHP电子邮件表单的标题中使用发件人的姓名和电子邮件地址 - Using a sender's name and email address in the header of a PHP email form 在 WooCommerce 订单和 email 通知上按名称排序费用 - Sort fees by name on WooCommerce Orders and email notifications
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM