Alter Subscription Expiry Date Range Using Subscriptions for WooCommerce

Using the following code snippet you can expand the monthly range of the subscription length after which the subscription expires with Subscriptions for WooCommerce. Currently, the plugin helps you to set the subscription length up to 24 months for month based subscriptions.

Add the code snippet below to the active child theme’s function.php file. Add the required length for the subscription by adding to the code and changing the range label and the second index of the subscription_ranges array.

The code snippet can also be used to alter the number of days, the number of weeks, and the number of year in the subscription length. Currently, the plugin supports up to 90 days for daily subscriptions, up to 52 weeks for week based subscriptions, and up to 5 years for year based subscriptions.

To extend the subscription length for days, weeks, or years, you need to change the first and second indexes of the subscription range array and the range label. For example, you can have the length of a daily subscription up to 90 days. To extend the number of days in the subscription length up to say 95, you need to change the code within the wt_add_length() function as:

up to the required length. Similarly for weeks and years.


  • Was this article helpful ?
  • YesNo

4 thoughts on “Alter Subscription Expiry Date Range Using Subscriptions for WooCommerce

  1. Luke says:

    Hi Mark & Safwana,

    Do you happen to know a way to set a fixed expiry date, ie. 30/6/2020, rather than a number of months / days from the subscription start?


  2. Niels de Vries says:

    Hi Safwana,

    This is exactly what I’m looking for! Thanks.
    However, adding the code doesn’t seem to work in case. I’ve added the following code to the functions.php file, but I can’t see 36 months as an option:

    function wt_add_length( $subscription_ranges, $subscription_period ) {

    $subscription_ranges[‘month’][36] = __(’36 months’, ‘xa-woocommerce-subscriptions’);

    return $subscription_ranges;

    add_filter( ‘hf_subscription_lengths’, ‘wt_add_length’, 10, 2 );

    Do you know if I perhaps have to change anything in the code?
    Many thanks!


    • Mark
      Mark says:

      Hi Niels,

      We tested the snippet and it is working fine. Kindly ensure that you have followed all steps carefully. Reach us via support link above if any issues.

Leave a Reply

Your email address will not be published. Required fields are marked *