Skip to content

Instantly share code, notes, and snippets.

@thenbrent
Last active April 2, 2021 10:25
Show Gist options
  • Save thenbrent/d1e10ab5e7fffda5b4d2 to your computer and use it in GitHub Desktop.
Save thenbrent/d1e10ab5e7fffda5b4d2 to your computer and use it in GitHub Desktop.
Add a new billing interval to WooCommerce Subscriptions to allow for longer intervals between subscription renewal payments. Specifically a new "8" interval to allow you to sell a subscription that renews every 8 days, weeks, months or years.
<?php
/**
* Plugin Name: WooCommerce Subscription Custom Interval
* Description: Add a custom 8 week subscription interval to WooCommerce Subscriptions
* Author: Brent Shepherd
* Version: 1.0
* License: GPL v2
*/
function eg_add_custom_subscription_interval( $subscription_intervals ) {
$subscription_intervals['8'] = sprintf( __( 'every %s', 'woocommerce-subscriptions' ), WC_Subscriptions::append_numeral_suffix( 8 ) );
return $subscription_intervals;
}
add_filter( 'woocommerce_subscription_period_interval_strings', 'eg_add_custom_subscription_interval' );
@jessepearson
Copy link

@jethromay I just copied it directly from above into my theme's functions.php file and it worked for me:


Image Link: https://d.pr/i/LjuZdZ

@jethromayuk
Copy link

@jessepearson yeah, sorry you're right! I was looking under the 'day/month/year' dropdown. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment