Skip to content

Instantly share code, notes, and snippets.

@bernattorras
Created November 12, 2019 09:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernattorras/a222a17de4c65102b13c66395c3ac4d4 to your computer and use it in GitHub Desktop.
Save bernattorras/a222a17de4c65102b13c66395c3ac4d4 to your computer and use it in GitHub Desktop.
Extend the subscription period intervals to a custom number
<?php
// Extend the subscription period intervals to a custom number
function eg_extend_subscription_period_intervals( $intervals ) {
$max_intervals = 30; // The maximum number of intervals you want to display
$intervals = array( 1 => _x( 'every', 'period interval (eg "$10 _every_ 2 weeks")', 'woocommerce-subscriptions' ) );
foreach ( range( 2, $max_intervals ) as $i ) {
$intervals[ $i ] = sprintf( _x( 'every %s', 'period interval with ordinal number (e.g. "every 2nd"', 'woocommerce-subscriptions' ), WC_Subscriptions::append_numeral_suffix( $i ) );
}
return $intervals;
}
add_filter( 'woocommerce_subscription_period_interval_strings', 'eg_extend_subscription_period_intervals' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment