How To Update Woocommerce Subscriptions Product Price String

Share Now

Let’s say we have 3 types of Subscription with a Subscription fee of $500.00

  1. Monthly
  2. Annually
  3. 2-Pay [Basically have to pay in every 6 Months]

Now on Woocommerce Subscription plugin, the price will show like this

$950.00 for 6 months and a $500.00 sign-up fee

Now what I like to do is change the price string in a way it will look more professional, For example, we can show Sign-Up fee text in the next line.

A code snippet I found on stack over flow

add_filter( 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string', 10, 3 );

function my_subs_price_string( $subscription_string, $product, $include ) {

var_dump($product); Various variables are available to us

return 'An initial easy payment of ' . 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 );

Now what I have to do is modify this code accrding to my need

#This is my code

*** Most important piece is var_dump($product);. We can get all the necessary information form this



#Now the cart will look like this

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert