在WooCommerce的最新更新中,他们已将Discounts改为Coupon(s)。这在订单总数表中。请参阅此屏幕截图以了解>清晰度https://prnt.sc/sq6xfh
我想尽可能将其更改为“折扣”,因为在您实际应用折扣后说“优惠券”并没有多大意义。理想情况下,最好根据需要显示“折扣”和“优惠券”行,因为有时您可以应用优惠券和折扣。
现在,我正在尝试更改屏幕快照中上面指出的Discount(s)标签。
我已经在插件核心文件中找到了代码,并且知道我无法更改,这是代码:
</tr>
<?php if ( 0 < $order->get_total_discount() ) : ?>
<tr>
<td class="label"><?php esc_html_e( 'Coupon(s):', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total">-
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
</td>
</tr>
<?php endif; ?>
我不确定如何通过我的functions.php在上面的代码中将Coupon(s)更改为Discounts
任何帮助表示赞赏。干杯尼克
您可以通过gettext
以下方式使用WordPress挂钩:
add_filter('gettext', 'custom_strings_translation', 20, 3);
function custom_strings_translation( $translated_text, $text, $domain ) {
global $pagenow, $typenow;
// Settings
$current_text = "Coupon(s):";
$new_text = "Discount(s):";
// Targeting admin single order pages
if( is_admin() && in_array($pagenow, ['post.php', 'post-new.php']) && 'shop_order' === $typenow && $current_text === $text ){
$translated_text = __( $new_text, $domain );
}
return $translated_text;
}
代码进入活动子主题(或活动主题)的functions.php文件中。经过测试和工作。
相关答案:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句