Hide the “free trial” text from Woocommerce Subscriptions price

大兔子大兔子 提交于 2019-12-24 07:39:09

问题


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.


回答1:


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;
}

Code goes in function.php file of your active child theme (or theme).

Tested and works.



来源:https://stackoverflow.com/questions/48936530/hide-the-free-trial-text-from-woocommerce-subscriptions-price

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!