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

Creating a custom subscription interval


The Subscriptions plugin already gives you the ability to create a day-long subscription, a month-long subscription, and subscriptions that can renew every other week. While it has a lot of intervals, it can't possibly have every one. If you want to have a subscription that renews every tenth week, you'll have to create a custom subscription interval. Using filters in Subscriptions, we can easily add this.

Getting ready

You must have the WooCommerce Subscriptions plugin installed and activated on your site. You should also have a subscription product already created.

How to do it…

In order to create a custom subscription interval, 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 line of code. This tells Subscriptions to look for your modifications to the possible intervals:

    add_filter( 'woocommerce_subscription_period_interval_strings...