WooCommerce Subscriptions – Custom renewal Interval

This is an extension of Joey’s: Add an extra billing interval to WooCommerce Subscriptions. It lets you add multiple custom renewal intervals:

/**
 * To include more frequencies, add a comma separated value within the bracket.
 * Eg, if you need an `every 9th` frequency here's how you'd update line#10 : $custom_frequency = array( 8, 9, 10 );
 */
function wcs_custom_frequency( $intervals ) {
	$custom_frequency = array( 8, 10 );

	foreach ( $custom_frequency as $frequency ) {
			$intervals[ $frequency ] = sprintf( __( 'every %s', 'custom-text-domain' ), WC_Subscriptions::append_numeral_suffix( $frequency ) );
	}
	return $intervals;
}
add_filter( 'woocommerce_subscription_period_interval_strings', 'wcs_custom_frequency' );

What does this do?

  • This function adds custom renewal intervals for WooCommerce Subscription Products.
  • The code as it is adds `every 8th` and `every 10th` custom frequency for Subscription renewals.
  • To include more frequencies, add a comma-separated value within the bracket.
  • Eg, if you need an `every 9th` frequency here’s how you’d update line#10 : $custom_frequency = array( 8, 9, 10 );
Subscription – Product Edit page

Usage:

You can either place the snippet on your child themes functions.php or use a plugin like Code Snippets to add the snippet.

Leave a Reply

Your email address will not be published.