How To Add Custom Billing Intervals To WooCommerce Subscriptions

Published: 6 months ago

Do you want to have more control over the billing intervals on your WooCommerce subscriptions? Setting custom billing intervals is easy and can help give your customers flexibility. In this article, we will take a look at how to add custom billing intervals to WooCommerce subscriptions. We will also take a look at some of the best practices you should follow when setting up these new settings so that everything works smoothly for both you and your customer.

WooCommerce subscriptions allow you to create a recurring payment for your customers. Depending on the subscription, this can be daily, monthly or yearly. The default billing interval is one month (or 30 days) but you have the option of changing it if need be. However, you're limited to every XX day/week/month, instead of being able to input whatever interval you want.

In order to add custom billing intervals, you need a WooCommerce Subscriptions plugin. This will change how the subscription works and allow you to set any interval you want- on whatever schedule is most convenient for your customer.

Now, to add the custom intervals, all you need to do is add the following code:

function eg_extend_subscription_period_intervals( $intervals ) {

$intervals[8] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 8 ) );

$intervals[12] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 12 ) );

$intervals[24] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 24 ) );

return $intervals;

}
add_filter( 'woocommerce_subscription_period_interval_strings', 'eg_extend_subscription_period_intervals' );

(Source)

This will add three additional items to the WooCommerce Subscriptions interval dropdown, every 8 days, every 12 days and every 24 days. To add additional intervals, just add another of this line:

$intervals[24] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 24 ) );

Change the 24 to whatever number of days you want the given subscription to renew on.

Now, you'll have custom intervals added to your WooCommerce subscriptions backend.

Join Our Newsletter
Here's what you get: A once a week newsletter that contains original content, aggregated posts, WordPress deals, and anything else we think you'd like. We don't spam or sell your email address. Unsub at any time.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
IsoGroup- Web Dev/Design, WordPress and More

Affiliate Disclosure: Some links on this website are affiliate links. We make commissions for purchases made through those links.

We only recommend items/tools that we've personally used and like.

Full Disclosure | FTC Statement

Join Our Newsletter
Over 4,000 Design Lovers and Problem Solvers.

Author

A relationship driven website creation company.

Connect

© ISOTROPIC, LLC 2016-2021
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram