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.