在 WooCommerce 管理产品页面设置中更改 "Regular price" 文本
Change "Regular price" text in WooCommerce admin product pages settings
我在 woocommerce 产品编辑页面设置的价格部分添加了 3 个额外的自定义字段。我想用 "List price" 代替 "Regular Price"。
如何在 Woocommerce 管理产品编辑页面设置中更改 "Regular price" 文本标签?可能吗?
2020 更新优化 (适用于管理员新产品和 WooCommerce 4+)
使用 WordPress "gettext
" 过滤器钩子中的自定义函数,您将能够在管理产品编辑和新产品页面中替换 (后端) 文本“正常价格”来自“标价”:
add_filter('gettext', 'change_backend_product_regular_price', 100, 3 );
function change_backend_product_regular_price( $translated_text, $text, $domain ) {
global $pagenow, $post_type;
if ( is_admin() && in_array( $pagenow, ['post.php', 'post-new.php'] )
&& 'product' === $post_type && 'Regular price' === $text && 'woocommerce' === $domain )
{
$translated_text = __( 'List price', $domain );
}
return $translated_text;
}
代码进入您的活动子主题(或活动主题)的 functions.php 文件。已测试并有效。
我在 woocommerce 产品编辑页面设置的价格部分添加了 3 个额外的自定义字段。我想用 "List price" 代替 "Regular Price"。
如何在 Woocommerce 管理产品编辑页面设置中更改 "Regular price" 文本标签?可能吗?
2020 更新优化 (适用于管理员新产品和 WooCommerce 4+)
使用 WordPress "gettext
" 过滤器钩子中的自定义函数,您将能够在管理产品编辑和新产品页面中替换 (后端) 文本“正常价格”来自“标价”:
add_filter('gettext', 'change_backend_product_regular_price', 100, 3 );
function change_backend_product_regular_price( $translated_text, $text, $domain ) {
global $pagenow, $post_type;
if ( is_admin() && in_array( $pagenow, ['post.php', 'post-new.php'] )
&& 'product' === $post_type && 'Regular price' === $text && 'woocommerce' === $domain )
{
$translated_text = __( 'List price', $domain );
}
return $translated_text;
}
代码进入您的活动子主题(或活动主题)的 functions.php 文件。已测试并有效。