If you're running a subscription site, there are bound to be things you want to customize to make your website reflect your brand. Subscriptions are loaded with hooks that developers can use to customize all sorts of things programmatically. We'll be manipulating the Subscriptions price string using a filter just to show how things are done.
You must have the WooCommerce Subscriptions plugin installed and activated on your site.
In order to customize the subscription price string, go through the following steps:
functions.php
file, located under wp-content/themes/your-theme-name/
, or create a custom WooCommerce plugin and open up that file.add_filter( 'woocommerce_subscriptions_price_string', 'woocommerce_cookbook_subscription_price_string', 10, 2 ); add_filter('woocommerce_subscriptions_product_price_string' , 'woocommerce_cookbook_subscription_price_string', 10, 2 );
Now we need to write the modifications. Add the following code:
function woocommerce_cookbook_subscription_price_string( $subscription_string, $product ) { $subscription_string = $subscription_string . '. In 2016 all subscriptions will get a price increase. Buy now to be grandfathered in.'; return $subscription_string; }
Look at your subscription on the frontend and you can see the addition we made to the price string.
There are dozens of filters you can use to modify all sorts of things in Subscriptions. If you're a developer, you can read through the developer docs at http://docs.woothemes.com/document/subscriptions/develop/.