隐藏Woocommerce订阅价格中的“免费试用"文本,但保留注册费 [英] Hide “free trial” text from Woocommerce Subscriptions price but keep the Sign-Up Fee
本文介绍了隐藏Woocommerce订阅价格中的“免费试用"文本,但保留注册费的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题的第一部分(隐藏Woocommerce订阅价格中的免费试用"文本)在以下很棒的帖子中得到了回答:
The first part of the question (Hide the "free trial" text from Woocommerce Subscriptions price) was answered in this awesome post:
但是,它删除了和xx注册费".删除免费试用文本后,是否可以保留注册费文本?
However, it removed the "and a xx sign-up fee". Is there any way to keep the sign up fee text after removing the free trial text?
推荐答案
已更新-尝试以下操作:
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 = get_post_meta( $product->get_id(), '_subscription_trial_length', true );
$speriod = get_post_meta( $product->get_id(), '_subscription_period', true );
$sfee = get_post_meta( $product->get_id(), '_subscription_sign_up_fee', true );
$sfee = wc_price($sfee);
$sign_up_fee = isset($args['sign_up_fee']) ? __(" and a $sfee sign-up fee", "woocommerce") : '';
if( $trial_length > 0 )
$price_string = $args['price'] . ' / ' . $speriod . $sign_up_fee;
return $price_string;
}
代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试,可以正常工作.
Code goes in function.php file of your active child theme (or active theme). Tested and works.
这篇关于隐藏Woocommerce订阅价格中的“免费试用"文本,但保留注册费的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文