This code works for me but it makes adjustments to every subscription on the website. I want to target a particular product or array of products so others are unaffected. that's issue I have with that code on other subscriptions
add_filter( 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string1', 10, 3 );
function my_subs_price_string1( $subscription_string, $product, $include ) {
/****
var_dump($product); Various variables are available to us
****/
return 'Today ' . wc_price( $product->subscription_sign_up_fee ) .
', a ' . $product->subscription_trial_length . ' ' . $product->subscription_trial_period .
' trial of the product, then an outright purchase of ' . wc_price( $product->subscription_price );
}
EDIT: I tried using a snippet from the post in the answer below. But for some reason, it just removes the string and doesn't replace chosen string. Here's the snippet.
function wc_subscriptions_custom_price_string( $pricestring ) {
global $product;
$products_to_change = array( 2212 );
if ( in_array( $product->id, $products_to_change ) ) {
$newprice = str_replace( 'on the 20th day of every 6th month', 'on the 20th November and 20th May', $pricestring );
}
return $newprice;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_custom_price_string' );
add_filter( 'woocommerce_subscription_price_string', 'wc_subscriptions_custom_price_string' );