[英]Change New Order email notification from name in Woocommerce
Email notification of New order process has 'My Blog'
title.新订单流程的电子邮件通知具有
'My Blog'
标题。
I look into Woocommerce setting but could not find it.我查看了 Woocommerce 设置,但找不到。
Any Idea how to change 'My Blog'
to 'X Company'
red underline text in attached images.任何想法如何将附加图像中的
'My Blog'
更改为'X Company'
红色下划线文本。
Plateform: Wordpress + Woocommerce平台:Wordpress + Woocommerce
Update:更新:
What you want to change is the "From name" and it can be changed using:您要更改的是“发件人名称”,可以使用以下方法进行更改:
add_filter('woocommerce_email_from_name', 'change_new_order_email_from_name', 10, 2 );
function change_new_order_email_from_name( $from_name, $email ){
if( $email->id === 'new_order' )
$from_name = __("ACME corp");
return $from_name;
}
Code goes in function.php file of your active child theme (or active theme).代码位于活动子主题(或活动主题)的 function.php 文件中。 Tested and works.
测试和工作。
Addition: To add custom placeholders for the email subject (for woocommerce 3.2+) :添加:为电子邮件主题添加自定义占位符(适用于 woocommerce 3.2+) :
// Only for woocommerce versions 3.2 + (up to 3.2)
add_filter( 'woocommerce_email_format_string' , 'custom_email_format_string', 20, 2 );
function custom_email_format_string( $string, $email ) {
// Get the instance of the WC_Order object
$order = $email->object;
// Additional wanted placeholders in the array of find / relace pairs
$additional_placeholders = array(
'{shop_company}' => __("ACME corp"),
);
// return the clean string with new replacements
return str_replace( array_keys( $additional_placeholders ), array_values( $additional_placeholders ), $string );
}
Code goes in function.php file of your active child theme (or active theme).代码位于活动子主题(或活动主题)的 function.php 文件中。 Tested and works.
测试和工作。
Then in your email settings, on the Subject field of an email notification you will be able to replace for example:
然后在您的电子邮件设置中,在电子邮件通知的主题字段中,您将能够替换例如:
Your {site_title} order receipt from {order_date}
by
经过
Your {shop_company} order receipt from {order_date}
Please use this WooCommerce hook woocommerce_email_subject_new_order
to change new order email title.请使用此 WooCommerce 挂钩
woocommerce_email_subject_new_order
更改新订单电子邮件标题。
add_filter( 'woocommerce_email_subject_new_order', 'customizing_new_order_subject', 10, 2 );
function customizing_new_order_subject( $formated_subject, $order ){
// Get an instance of the WC_Email_New_Order object
$email = WC()->mailer->get_emails()['WC_Email_New_Order'];
// Get unformatted subject from settings
$subject = $email->get_option( 'subject', $email->get_default_subject() );
// Loop through order line items
$product_names = array();
foreach( $order->get_items() as $item )
$product_names[] = $item->get_name(); // Set product names in an array
// Set product names in a string with separators (when more than one item)
$product_names = implode( ' - ', $product_names );
// Replace "{product_name}" by the product name
$subject = str_replace( '{product_name}', $product_names, $subject );
// format and return the custom formatted subject
return $email->format_string( $subject );
}
Go to去
WooCommerce > Settings > Emails > Processing Orders.
Here you will find a field called "Email Subject"
.在这里您会找到一个名为
"Email Subject"
的字段。 Here, change {site_title}
to whatever you want it to appear.在这里,将
{site_title}
更改为您希望它出现的任何内容。
Alternatively, if you want to change the value of {site_title}
itself, then head over to Settings > General
.或者,如果您想更改
{site_title}
本身的值,请转到Settings > General
。
Here you will find the field called Site Title.您将在此处找到名为“站点标题”的字段。 Change it to whatever you want it to appear.
将其更改为您希望它出现的任何内容。
Let me know if it works!让我知道它是否有效!
I found the solution after digging, its very easy.我在挖掘后找到了解决方案,非常简单。
WooCommerce>Setting>Emails WooCommerce>设置>电子邮件
At the bottom, there is section where you can header and footer text.在底部,有一个部分,您可以在其中添加页眉和页脚文本。
Simple.简单的。
Really appreciate your help @LoicTheAztec非常感谢您的帮助@LoicTheAztec
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.