Changing in WooCommerce email notification Order Item table quot;Productquot; label(在WooCommerce电子邮件通知订单表中更改产品标签)
本文介绍了在WooCommerce电子邮件通知订单表中更改产品标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将WooCommerce订单表电子邮件通知中的文本(标签)"产品"更改为"票证"。
我将如何执行此操作?
有可能吗?
谢谢
推荐答案
首先,我们需要获取针对所有电子邮件通知的电子邮件ID。唯一的方法是先获取它,然后在全局变量中设置值。
然后在Wordpressgettext
操作挂钩中的自定义函数中,我们可以更改(翻译)所有电子邮件通知中的"产品"。
代码如下:
## 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;
}
此代码放在活动子主题(或主题)的函数.php文件或任何插件文件中。
此代码在从2.6.x到3.0+的WooCommerce上进行了测试,并且可以正常工作。
这篇关于在WooCommerce电子邮件通知订单表中更改产品标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:在WooCommerce电子邮件通知订单表中更改产品标签
基础教程推荐
猜你喜欢
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01