更改WooCommerce电子邮件通知订单项目表“产品”标签
答
首先,我们需要获取电子邮件ID来定位所有电子邮件通知。唯一的方法是先取得它并在全局变量中设置该值。
然后在一个自定义函数中挂钩Wordpress gettext
动作钩子,我们可以在所有电子邮件通知中更改(翻译)“产品”。
这里是代码:
## Tested on WooCommerce 2.6.x and 3.0+
// Setting the email_is as a global variable
add_action('woocommerce_email_before_order_table', 'the_email_id_as_a_global', 1, 4);
function the_email_id_as_a_global($order, $sent_to_admin, $plain_text, $email){
$GLOBALS['email_id_str'] = $email->id;
}
add_filter('gettext', 'wc_renaming_email_label', 50, 3);
function wc_renaming_email_label($translated_text, $untranslated_text, $domain) {
// Getting the email ID global variable
$refNameGlobalsVar = $GLOBALS;
$email_id = $refNameGlobalsVar['email_id_str'];
if(!is_admin() && $email_id) {
if($untranslated_text == 'Product')
$translated_text = __('Ticket', $domain);
}
return $translated_text;
}
此代码放在你的活跃儿童主题(或主题)的function.php文件或也以任何插件文件。
此代码在WooCommerce从2.6.x到3.0+以上进行测试,并且可以正常工作。
答
如果你不想修改WooCommerce文件,如果你想从WooCommerce文件编辑使用这个插件https://wordpress.org/plugins/woo-custom-emails/
,然后修改/可湿性粉剂内容的电子邮件模板/ plugins/woocommerce/templates/emails/
+0
好像没有在电子邮件模板中编辑标签的选项 –
+0
请解释哪一个是标签? –
刚刚做到了! :) 有用! :) 谢谢!!! –