Book Image

WooCommerce Cookbook

By : Patrick Rauland
Book Image

WooCommerce Cookbook

By: Patrick Rauland

Overview of this book

Table of Contents (17 chapters)
WooCommerce Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Customizing the subscription price string


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.

Getting ready

You must have the WooCommerce Subscriptions plugin installed and activated on your site.

How to do it…

In order to customize the subscription price string, go through the following steps:

  1. Open up your theme's functions.php file, located under wp-content/themes/your-theme-name/, or create a custom WooCommerce plugin and open up that file.

  2. Add the following two lines of code. These tell Subscriptions to look for your modifications to the price string:

    add_filter( 'woocommerce_subscriptions_price_string', 'woocommerce_cookbook_subscription_price_string', 10, 2 );
    add_filter('woocommerce_subscriptions_product_price_string...