在Woocommerce中更改某些特定电子邮件通知的电子邮件主题 [英] Change email subjects for some specific email notifications in Woocommerce
问题描述
我想标准化电子邮件主题的结构(对于所有Woocommerce电子邮件通知). 我正在使用所有可用的过滤器从这里
I would like to standardize structure of email subjects (for all Woocommerce emails notifications). Im using all available filters from here
但是保留",取消",退款"和订单失败"电子邮件主题又如何呢?
有没有办法更改这些电子邮件的电子邮件主题?
But what about "On hold", "Cancelled", "Refunded" and "Failed order" email subjects?
Is there way to change email subject for those emails?
推荐答案
在具有正确过滤器挂钩的4个挂钩函数下面,您可以自定义电子邮件主题为保留",已取消",已退款"和订单失败"通知:
Below the 4 hooked functions with the correct filter hooks, that will allow you to customize the email subjects for "On hold", "Cancelled", "Refunded" and "Failed order" notifications:
add_filter( 'woocommerce_email_subject_customer_on_hold_order', 'customizing_on_hold_email_subject', 10, 2 );
function customizing_on_hold_email_subject( $formated_subject, $order ){
return __("This is the custom on hold order email notification subject", "woocommerce");
}
add_filter( 'woocommerce_email_subject_cancelled_order', 'customizing_cancelled_email_subject', 10, 2 );
function customizing_cancelled_email_subject( $formated_subject, $order ){
return __("This is the custom on cancelled email notification subject", "woocommerce");
}
add_filter( 'woocommerce_email_subject_customer_refunded_order', 'customizing_refunded_email_subject', 10, 2 );
function customizing_refunded_email_subject( $formated_subject, $order ){
return __("This is the custom on refunded email notification subject", "woocommerce");
}
add_filter( 'woocommerce_email_subject_failed_order', 'customizing_failed_email_subject', 10, 2 );
function customizing_failed_email_subject( $formated_subject, $order ){
return __("This is the custom on failed email notification subject", "woocommerce");
}
代码进入活动子主题(或活动主题)的function.php文件.
经过测试,可以正常工作.
Tested and works.
您可以使用
WC_Order
对象自变量$order
使用动态订单数据自定义主题...
You can use the
WC_Order
object argument$order
to customize the subjects with dynamic order data…
例如 (具有动态订单ID和订单格式的日期已修改):
add_filter( 'woocommerce_email_subject_cancelled_order', 'customizing_cancelled_email_subject', 10, 2 );
function customizing_cancelled_email_subject( $formated_subject, $order ){
$modified = $order->get_date_modified(); // Get date modified WC_DateTime object
return sprintf( __('Order #%d was cancelled on %s', 'woocommerce'), $order->get_id(), $modified->date_i18n( 'l jS \of F Y \a\t h:i:s A' ) );
}
与
相关:更改电子邮件主题Woocommerce 3中的自定义订单状态
这篇关于在Woocommerce中更改某些特定电子邮件通知的电子邮件主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!