问题的第一部分(隐藏 Woocommerce 订阅价格中的“免费试用”文本)在这篇很棒的帖子中得到了回答:
隐藏 Woocommerce 订阅价格中的“免费试用”文本 https://stackoverflow.com/questions/48936530/hide-the-free-trial-text-from-woocommerce-subscriptions-price/48938813#48938813
然而,它删除了“和xx注册费”。删除免费试用文本后有什么办法保留注册费文本吗?
Updated- 尝试以下操作:
add_filter( 'woocommerce_subscriptions_product_price_string', 'subscriptions_custom_price_string', 20, 3 );
function subscriptions_custom_price_string( $price_string, $product, $args ) {
// Get the trial length to check if it's enabled
$trial_length = $product->get_meta('_subscription_trial_length');
$subscr_period = $product->get_meta('_subscription_period');
$subscr_fee = wc_price( $product->get_meta('_subscription_sign_up_fee') );
$sign_up_fee = isset($args['sign_up_fee']) ? __(" and a $subscr_fee sign-up fee", "woocommerce") : '';
if( $trial_length > 0 )
$price_string = $args['price'] . ' / ' . $subscr_period . $sign_up_fee;
return $price_string;
}
代码位于活动子主题(或活动主题)的 function.php 文件中。经过测试并有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)