WebToffee Logo
  • Home
  • Plugins
  • Blog
  • Documentation
  • Support
Login
0

  • Getting Started
    • Plugin Setup
    • Subscription Synchronization
  • Subscriptions Payment Gateway Guide
    • Change Payment Method
    • PayPal payment method for subscription
    • Supported Payment Methods
  • Manually Add or Modify Subscriptions
    • Add/Edit subscription manually
  • Email Notifications
    • Subscription Notifications
  • FAQ
    • Change 'Add to Cart' button text
    • Redirect to custom page after purchase
    • Alter subscription expiry date range
    • Remove tab menus from My Account page
    • Subscription coupons
    • Alter default subscription billing interval
    • Change order status after payment
  • Changelog
    • Version 3.2.6

Documentation/Subscriptions for WooCommerce/Alter Subscription Expiry Date Range Using Subscriptions for WooCommerce

Alter Subscription Expiry Date Range Using Subscriptions for WooCommerce

Last updated on December 8, 2020

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:

$subscription_ranges['day'][91] = __('91 days', 'xa-woocommerce-subscriptions');

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

  • Was this article helpful?
  • Yes, thanks!Not really

This article posted in Code Snippet, Documentation, FAQ, Subscriptions for WooCommerce

Written by

Safwana

Safwana is a technical content writer for WebToffee. She loves working in WordPress and writing about it.

Comments (6)

  1. Schalk Joubert

    Schalk Joubert

    July 6, 2020

    Hi, any chance you can point me in the right direction on how to set a certain time for expiry? So no matter when the subscription is purchased, it will expire on 30 May 2021.
    Thank you
    Schalk

    Reply
    • Mark

      Mark

      July 8, 2020

      You can only set the subscription expiry in number of day, weeks or months.

      Reply
  2. Luke

    July 8, 2019

    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?

    Luke

    Reply
    • Mark

      Mark

      July 9, 2019

      Hi,

      Please try editing the subscription order manually and change the subscription end date.

      Reply
  3. Niels de Vries

    January 11, 2019

    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!

    Niels

    Reply
    • Mark

      Mark

      January 14, 2019

      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.

      Reply

Got any query? Please leave a comment or reach out to our support

Cancel reply

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

We develop awesome WordPress plugins & WooCommerce extensions to help build successful online businesses.

© 2021 WebToffee. All rights reserved.

Our plugins

  • GDPR Cookie Consent
  • PDF Invoices & Packings Slips
  • Product Import Export Plugin
  • User & Customer Import Export
  • Import Export Suite
  • Sequential Order Numbers
  • Smart Coupons for WooCommerce
  • URL Coupons for WooCommerce
  • PayPal Express Checkout
  • Stripe Payment Gateway
  • Subscriptions for Woocommerce
  • Product Catalog Sync for Facebook
  • PrintNode for PDF Invoices
  • Order, coupon, subscriptions for WooCommerce
  • WordPress Backup and Migration
View more +

Get Started

  • Plugins
  • Testimonials
  • Affiliates
  • We're hiring

Help & Support

  • Documentation
  • Documentation (Basic)
  • FAQ
  • Support

Company

  • Terms & Conditions
  • Privacy Policy
  • Refund policy
  • Support policy
  • License Activation

© 2021 WebToffee. All rights reserved.

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. However you may visit Cookie Settings to provide a controlled consent.
Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of the basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website, to store user preferences and provide you with content and advertisements that are relevant. Such cookies will be stored on your browser but only upon procuring consent.

You will also have the option to opt-out of these cookies should you want to. But opting out of some of these cookies may have an effect on your browsing experience as per the descriptions elucidated against the respective categories below.

Necessary
Always Enabled

The cookies defines under this category are absolutely essential for the website to function. Hence they are loaded by default irrespective if user consent.

CookieDescription
PHPSESSIDThis cookie is native to PHP applications. The cookie is used to store and identify a users' unique session ID for the purpose of managing user sessions on the website. The cookie is a session cookie and is deleted when all the browser windows are closed.
viewed_cookie_policyThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not a user has consented to the use of cookies. It does not store any personal data.
Analytics

Analytics cookies help us understand how our visitors interact with the website. It helps us understand the number of visitors, where the visitors are coming from, and the pages they navigate. The cookies collect this data and are reported anonymously.

CookieDescription
_gaThis cookie is installed by Google Analytics. The cookie is used to calculate visitor, session, campaign data and keep track of site usage for the site's analytics report. The cookies store information anonymously and assigns a randomly generated number to identify unique visitors.
_gat_gtagIdentification code of website for tracking visits.
_gidThis cookie is installed by Google Analytics. The cookie is used to store information on how visitors use a website and helps in creating an analytics report of how the website is doing. The data collected including the number visitors, the source where they have come from, and the pages visited in an anonymous form.
_hjidHotjar cookie. This cookie is set when the customer first lands on a page with the Hotjar script. It is used to persist the random user ID, unique to that site on the browser. This ensures that behavior in subsequent visits to the same site will be attributed to the same user ID.
_hjIncludedInSampleThis cookie is set to let Hotjar know whether that visitor is included in the sample which is used to generate heatmaps, funnels, recordings, etc.
has_recent_activityThis cookie is used to signal to the code repository website if the user has browsed other website resources during the current session.
tk_aiGathers information for our own first-party analytics tool about how our services are used. A collection of internal metrics for user activity and is used to improve user experience.
tk_lrThis cookie is set by the JetPack plugin on sites using WooCommerce. This is a referral cookie used for analyzing referrer behavior for Jetpack.
tk_orThis cookie is set by the JetPack plugin on sites using WooCommerce. This is a referral cookie used for analyzing referrer behavior for Jetpack.
tk_qsGathers information for our own first-party analytics tool about how our services are used. A collection of internal metrics for user activity and is used to improve user experience.
tk_r3dThe cookie is installed by JetPack. Used for the internal metrics for user activities to improve user experience.
Advertisement

Advertisement cookies help us provide our visitors with relevant ads and marketing campaigns.

CookieDescription
_fbpThis cookie is set by Facebook to deliver advertisements when they are on Facebook or on a digital platform powered by Facebook advertising after visiting this website.
frThe cookie is set by Facebook to show relevant advertisements to the users and measure and improve the advertisements. The cookie also tracks the behavior of the user across the web on sites that have Facebook Pixel or Facebook social plugin.
Preferences

Preference cookies are used to store user preferences to provide them with content that is customized accordingly. This includes the language of the website or the location of the visitor.

CookieDescription
_gh_sessThis cookie is used to preserve users' states across page requests.
Save & Accept