Option to renew license or post date grant start and expire

Created on 11 February 2014, over 11 years ago
Updated 19 August 2025, 5 days ago

There is a very simple use case for this module to allow for "subscription" products to sites where a user is buying a role. For example I could buy a yearly subscription to the site and get granted a simple role. This is easy to do with the module out of the box with the role license class. There are some people using this workflow that don't require or want recurring billing, orders, etc. They simply just want to send a reminder email out and have the user come back and purchase another licenses to "renew" their membership or subscription.

Ideally if I buy a licenses, it would check to see if I already have one for this particular product and extend the expiration date instead or make the start of the new licenses start when the current one expires so there is no overlapping time.

I have spoken to bojanz in IRC about this and he recommended that I simply check for this inside hook_form_commerce_cart_add_to_cart_form_alter, look for existing licenses and set it to $form_state['line_item']->commerce_license. Then when it comes time to grant, we simply extend with ->renew()

This seems pretty straight forward, the only issue is that this will require users to be logged in before they could add these types of license products to the cart, which I don't think is the case for most people. Thoughts on that?

The alternative is instead of renewing/extending licenses I can post date the start of new licenses to exactly when the current ones expire. When the grant happens, we have a user on the order and it could technically all happing in the single save method on the license.

Would love some thoughts on all of this, specificity best practices so I can write this as a patch and new feature to the module and not a separate module. My main goal in this is to get this simple subscription type setup so I can end of life the Commerce Subscription Product module.

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mrconnerton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024