将发件人电子邮件更改为 Woocommerce 中的客户账单电子邮件
Change the sender email to the customer billing email in Woocommerce
我需要将订单邮件发件人更改为客户邮箱。
功能变更return邮箱为:
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 );
}
是否存在可以获取发件人电子邮件客户电子邮件的过滤器?我需要产品的供应商收到客户的电子邮件,这样他就可以更轻松地回复。
尝试使用以下内容:
// 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 文件。已测试并有效。
我需要将订单邮件发件人更改为客户邮箱。
功能变更return邮箱为:
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 );
}
是否存在可以获取发件人电子邮件客户电子邮件的过滤器?我需要产品的供应商收到客户的电子邮件,这样他就可以更轻松地回复。
尝试使用以下内容:
// 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 文件。已测试并有效。