隐藏“免费试用" Woocommerce订阅价格中的文字 [英] Hide the "free trial" text from Woocommerce Subscriptions price

查看:93
本文介绍了隐藏“免费试用" Woocommerce订阅价格中的文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图从我的产品,购物车和结帐页面中删除有XX天的免费试用期".我需要使该功能仍然有效,而不必在产品详细信息中表示它.

I am trying to remove the "with a XX day free trial" from my product, cart and checkout pages. I need to have the feature still work without having to express it in the product details.

推荐答案

可以使用过滤器挂钩 'woocommerce_subscriptions_product_price_string' 用于此挂钩函数,方法是:

It is possible using the filter hook 'woocommerce_subscriptions_product_price_string' for this hooked function, this way:

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 );
    if( $trial_length > 0 )
        $price_string = $args['price'];

    return $price_string;
}

代码进入活动的子主题(或主题)的function.php文件中.

经过测试,可以正常工作.

Tested and works.

这篇关于隐藏“免费试用" Woocommerce订阅价格中的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆