【问题标题】:Change the sender email to the customer billing email in Woocommerce在 Woocommerce 中将发件人电子邮件更改为客户帐单电子邮件
【发布时间】:2018-09-25 14:42:11
【问题描述】:
我需要将订单电子邮件发件人更改为客户电子邮件。
返回邮件的函数变化是:
public function get_from_address() {
$from_address = apply_filters( 'woocommerce_email_from_address', get_option( 'woocommerce_email_from_address' ), $this );
return sanitize_email( $from_address );
}
是否存在可以让我获取发件人电子邮件客户电子邮件的过滤器?我需要产品的供应商收到客户的电子邮件,这样他就可以更轻松地回复。
【问题讨论】:
标签:
php
wordpress
woocommerce
orders
email-notifications
【解决方案1】:
尝试使用以下内容:
// Change email sender name
add_filter( 'woocommerce_email_from_name', 'custom_email_from_name', 20, 2 );
function custom_email_from_name( $from_name, $wc_email ){
// Get the WC_Order object instance
$order = $wc_email->object;
$from_name = $order->get_formatted_billing_full_name(); // Customer ful name
return $from_name;
}
// Change email sender address
add_filter( 'woocommerce_email_from_address', 'custom_email_from_address', 20, 2 );
function custom_email_from_address( $from_email, $wc_email ){
// Get the WC_Order object instance
$order = $wc_email->object;
$from_email = $order->get_billing_email(); // Customer billing email
return $from_email;
}
代码进入您的活动子主题(或活动主题)的 function.php 文件中。经过测试并且可以工作。