Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save WillBrubaker/f01bc7ea4e492c6f04c5 to your computer and use it in GitHub Desktop.

Select an option

Save WillBrubaker/f01bc7ea4e492c6f04c5 to your computer and use it in GitHub Desktop.
Adds custom durations to woocommerce-subscriptions
<?php
//* Do NOT include the opening php tag
add_filter( 'woocommerce_subscription_lengths', 'wooninja_custom_subscription_duration' );
/**
* Filters the subscription lengths available
* @param array $ranges the array of ranges (lengths)
* @return array $ranges the filtered array of ranges (lengths)
*/
function wooninja_custom_subscription_duration( $ranges ) {
//add a range of 180 days
$ranges['day'][180] = '180 days';
//add a range of 104 weeks
$ranges['week'][104] = '104 weeks';
//add a range of 36 months
$ranges['month'][36] = '36 months';
//add a range of 6 years
$ranges['year'][6] = '6 years';
return $ranges;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment