Last active
May 14, 2024 21:04
-
-
Save thenbrent/7237105 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
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!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ) {
}
add_filter( 'woocommerce_subscription_period_interval_strings', 'eg_extend_subscription_period_intervals' );