WooCommerce -> Settings -> EmailS ->
前两个选项"FROM: Name, FROM: Email"
是发件人的电子邮件和名称。下订单时,会通过相同的发件人电子邮件和姓名(我们从管理信息中心设置)向商店经理和客户发送通知电子邮件。
当Customer
回复该电子邮件时,他基本上会回复Shop Manager
并且工作正常。
但Shop Manager
收到来自其(给定)电子邮件地址的通知电子邮件,实际上会有客户的电子邮件。
P.S:我希望店铺经理从客户的账单电子邮件中收到电子邮件,客户可以通过商店经理给出电子邮件。
答案 0 :(得分:1)
我能想到实现这一目标的唯一方法是使用其中一个系统操作挂钩以编程方式生成Shop Manager通知电子邮件。由于“from”设置中只有一个字段,因此将对所有出站消息使用(默认情况下)。
也就是说,请查看https://wordpress.org/plugins/code-snippets/处的Code Snippets插件。您可以在此处放置一些代码(并将其保存到数据库中,并在运行时包含系统代码),这可能会在生成新订单时生成此程序化电子邮件。
希望它有所帮助。
答案 1 :(得分:1)
在完成您的问题之后,对于店主而言,它需要像邮件应该从地址发送作为客户的电子邮件地址,以便他可以在单个电子邮件线程中回复每个订单。
//filter for the "mail from" email address which is set in WooCommerce Settings Email Tab-> Email Sender Options -> "From" Email Address which is generally set to the shop admin email address or a support team email address.
add_filter('wp_mail_from', 'wdm_sent_from_email', 99, 1);
//function which will change the mail from email address to the the Customer's billing address if the mail this filter is running which sending mail to the admin.
function wdm_sent_from_email( $sent_from = '' ) {
//check whether our custom parameter is set or not.
if ( isset($_POST['wdm_sent_to_admin']) ) {
//check whether the mail is sent to the admin and other recieptent other than customer
if ( $_POST['wdm_sent_to_admin'] ) {
//set it to the customer's billing email
$sent_from = $_POST['billing_email'];
//set this parameter back to false
$_POST['wdm_sent_to_admin'] == false;
}
}
return $sent_from;
}
//filter for email from name
add_filter('wp_mail_from_name', 'wdm_sent_from_name', 99, 1);
function wdm_sent_from_name( $sent_from_name = '' ) {
//check whether our custom parameter is set or not.
if ( isset($_POST['wdm_sent_to_admin_from_name']) ) {
//check whether the mail is sent to the admin and other recieptent other than customer
if ( $_POST['wdm_sent_to_admin_from_name'] ) {
//set sent mail from name eg. "Website-Name customer"
$sent_from_name = wp_specialchars_decode(esc_html(get_option('woocommerce_email_from_name')), ENT_QUOTES) . " customer";
//set this parameter back to false
$_POST['wdm_sent_to_admin_from_name'] = false;
}
}
return $sent_from_name;
}
//action were we will set and the parameter to indicate whether the mail is sent to admin or customers.
add_action('woocommerce_email_header', 'wdm_header_function', 99, 1);
function wdm_header_function( $email_heading ) {
if ( $email_heading == 'New customer order' ) {
//parameter to indicate whether to change the from email in the mail.
$_POST['wdm_sent_to_admin'] = true;
//parameter to indicate whether to change the from name in the mail.
$_POST['wdm_sent_to_admin_from_name'] = true;
//Just to indicate in mail sent to admin that the sent from email is set in code.
echo "<b>Its Because you have chosen to have this email sent from Customer's Email id.</b>";
} else {
//parameter to indicate whether to change the from email in the mail.
$_POST['wdm_sent_to_admin'] = false;
//parameter to indicate whether to change the from name in the mail.
$_POST['wdm_sent_to_admin_from_name'] = false;
}
}
注意:这可能会在您查看旁边的邮件时显示“此邮件可能未由以下邮件发送:(您的客户的帐单邮寄地址)”,这可能会给您和提醒消息,因为这不是真的由客户发送给您。
试试上面的代码并了解它是否适合您并完成您的目的。
答案 2 :(得分:0)
我认为你也可以使用wordpress钩子:
// Function to change email address
function wpb_sender_email( $original_email_address ) {
return 'tim.smith@example.com';
}
// Function to change sender name
function wpb_sender_name( $original_email_from ) {
return 'Tim Smith';
}
// Hooking up our functions to WordPress filters
add_filter( 'wp_mail_from', 'wpb_sender_email' );
add_filter( 'wp_mail_from_name', 'wpb_sender_name' );