Hide the “free trial” text from Woocommerce Subscr

2019-07-26 03:20发布

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条回答
够拽才男人
2楼-- · 2019-07-26 03:46

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.

查看更多
登录 后发表回答