前两个选项"FROM: Name, FROM: Email"是发件人的电子邮件地址和姓名。下订单时,将从同一发件人的电子邮件地址和姓名(我们从管理仪表板设置)向商店经理和客户发送一封通知电子邮件。
当Customer回复这封邮件时,他基本上回复了Shop Manager,它工作得很好。
但是Shop Manager从他(给定的)电子邮件地址收到通知电子邮件,实际上是客户的电子邮件。
附注:我希望店铺经理从客户的账单电子邮件中获得电子邮件,客户从店铺经理的给定电子邮件中获得电子邮件。
发布于 2015-05-29 02:21:03
要实现这一点,我能想到的唯一方法是使用其中一个系统操作钩子以编程方式生成Shop Manager通知电子邮件。由于"from“设置中只有一个字段,因此(默认情况下)它将用于所有出站消息。
也就是说,可以在https://wordpress.org/plugins/code-snippets/上查看代码片段插件。您可以在此处放置一些代码(它将保存到DB中,并在运行时包含系统代码),这些代码可以在生成新订单时生成此程序性电子邮件。
希望能有所帮助。
发布于 2015-06-01 14:30:01
看过你的问题后,对于店主来说,它需要像邮件应该已经发送的发件人地址一样作为客户的电子邮件地址,这样他就可以在单个电子邮件线程中回复每个订单。
//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;
}
}注意:在查看您身边的消息时,这可能会给您一个警告消息,提示“此消息可能不是由:(您的客户的帐单地址)发送的”,因为这不是真正由客户发送给您的消息。
尝试上面的代码,让我知道它是否适用于您并实现您的目标。
发布于 2017-05-03 13:41:30
我认为你也可以使用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' );https://stackoverflow.com/questions/30507977
复制相似问题