Skip to content

Instantly share code, notes, and snippets.

@mattpramschufer
Created February 14, 2018 14:22
Show Gist options
  • Save mattpramschufer/7645f0b61c8f4e2fe8921bedac259d0f to your computer and use it in GitHub Desktop.
Save mattpramschufer/7645f0b61c8f4e2fe8921bedac259d0f to your computer and use it in GitHub Desktop.
Extend WooCommerce Subscriptions Timeframes
<?php
/**
* Plugin Name: Extend WooCommerce Subscription Intervals
* Description: Add custom billing & subscription intervals to WooCommerce Subscriptions
* Author: Matt Pramschufer
* Author URI: https://emoxie.com
* Version: 1.0
* License: GPL v2
*/
function eg_extend_subscription_period_intervals( $intervals ) {
$intervals[6] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 6 ) );
$intervals[7] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 7 ) );
$intervals[8] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 8 ) );
$intervals[9] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 9 ) );
$intervals[10] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 10 ) );
$intervals[11] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 11 ) );
$intervals[12] = sprintf( __( 'every %s', 'my-text-domain' ), WC_Subscriptions::append_numeral_suffix( 12 ) );
return $intervals;
}
add_filter( 'woocommerce_subscription_period_interval_strings', 'eg_extend_subscription_period_intervals' );
function eg_extend_subscription_lengths( $subscription_lengths ) {
$subscription_lengths['year'][6] = WC_Subscriptions_Manager::get_subscription_period_strings( 6, 'year' );
$subscription_lengths['year'][7] = WC_Subscriptions_Manager::get_subscription_period_strings( 7, 'year' );
$subscription_lengths['year'][8] = WC_Subscriptions_Manager::get_subscription_period_strings( 8, 'year' );
$subscription_lengths['year'][9] = WC_Subscriptions_Manager::get_subscription_period_strings( 9, 'year' );
$subscription_lengths['year'][10] = WC_Subscriptions_Manager::get_subscription_period_strings( 10, 'year' );
return $subscription_lengths;
}
add_filter( 'woocommerce_subscription_lengths', 'eg_extend_subscription_lengths' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment