Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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' );
@tanguy22950
Copy link

tanguy22950 commented Sep 9, 2020

Hi,

It's possible to explain where exactly we put it in our code?

@jessepearson
Copy link

jessepearson commented Oct 18, 2020

@tanguy22950 Something like this would go directly into the functions.php file of your child theme, or it could be added through a plugin like Code Snippets.

@jessepearson
Copy link

jessepearson commented Nov 19, 2020

@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

jethromayuk commented Nov 19, 2020

@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