Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Add a new billing interval to WooCommerce Subscriptions. Specifically a "every 10 weeks" billing interval to selling a subscription to something and be charged every 10 weeks.
<?php
/**
* Plugin Name: Extend WooCommerce Subscription Intervals
* Description: Add a "every 10 weeks" billing interval to WooCommerce Subscriptions
* Author: Brent Shepherd
* Author URI: http://brent.io
* Version: 1.0
* License: GPL v2
*/
function eg_extend_subscription_period_intervals( $intervals ) {
$intervals[10] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 10 ) );
return $intervals;
}
add_filter( 'woocommerce_subscription_period_interval_strings', 'eg_extend_subscription_period_intervals' );
@josephabrahamweb

This comment has been minimized.

Show comment Hide comment
@josephabrahamweb

josephabrahamweb Aug 1, 2015

How do I add this to my plugin directory? Thanks!

How do I add this to my plugin directory? Thanks!

@josephabrahamweb

This comment has been minimized.

Show comment Hide comment
@josephabrahamweb

josephabrahamweb Aug 3, 2015

I figured out how silly my question was and I feel a little embarrassed. You just upload the file as you would any other plugin. You can see it in action here. https://savagecatfood.com/purchase/membership/

I figured out how silly my question was and I feel a little embarrassed. You just upload the file as you would any other plugin. You can see it in action here. https://savagecatfood.com/purchase/membership/

@robbiemacvicar

This comment has been minimized.

Show comment Hide comment
@robbiemacvicar

robbiemacvicar Jan 21, 2016

Is it possible to add more than one additional interval? For example I want to add the option for every 8, 12 and 24 weeks. I tried adding the above code in two separate plugins but there was a fatal error and I was only allowed one active install. Thank you!

Is it possible to add more than one additional interval? For example I want to add the option for every 8, 12 and 24 weeks. I tried adding the above code in two separate plugins but there was a fatal error and I was only allowed one active install. Thank you!

@robbiemacvicar

This comment has been minimized.

Show comment Hide comment
@robbiemacvicar

robbiemacvicar Jan 21, 2016

Sorry I think I just figured it out by using the code below. Is this correct and will it function properly?

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' );

Sorry I think I just figured it out by using the code below. Is this correct and will it function properly?

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' );

@deanklatt

This comment has been minimized.

Show comment Hide comment
@deanklatt

deanklatt Jun 9, 2017

is there a trick to getting this plugin to work with variable subscriptions? I'm trying to allow my customers to select delivery (& therefore subscription billing period) for our products on a monthly, 2nd month, 3rd month etc basis. I can do monthly or yearly options in variable, which is fine, but i need a couple more interval options. This plugin allows me to change to 'every 2nd month' or 'every 3rd month' etc. for simple subscriptions, but not offer as an option in variable subscriptions. How can I offer the extra billing intervals as options for variable subscriptions on a product? Tks

is there a trick to getting this plugin to work with variable subscriptions? I'm trying to allow my customers to select delivery (& therefore subscription billing period) for our products on a monthly, 2nd month, 3rd month etc basis. I can do monthly or yearly options in variable, which is fine, but i need a couple more interval options. This plugin allows me to change to 'every 2nd month' or 'every 3rd month' etc. for simple subscriptions, but not offer as an option in variable subscriptions. How can I offer the extra billing intervals as options for variable subscriptions on a product? Tks

@navdeepsingh

This comment has been minimized.

Show comment Hide comment
@navdeepsingh

navdeepsingh Feb 9, 2018

Thanks for Help!

Thanks for Help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment