-
-
Save thenbrent/7237105 to your computer and use it in GitHub Desktop.
<?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' ); |
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/
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!
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' );
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
Thanks for Help!
How do I add this to my plugin directory? Thanks!