Allow a license renewal to be purchased

Created on 30 December 2015, almost 9 years ago
Updated 7 November 2023, about 1 year ago

I'm running a subscription site and using Commerce License Role to allow users to purchase a user role which provides access to the system.

On expiry, emails are sent to the users reminding them that they should renew their subscription. What I want to happen is that the system can find any existing licenses and renew them for the required amount of time rather then issuing a new license.

I've been keeping an eye on https://www.drupal.org/node/2193305 but that thread has gone down the route of changing the dates on a newly purchased license so it extends the existing membership. I want to explore the use case above and thought that it deserves a thread of it's won distinct from https://www.drupal.org/node/2193305 .

My initial problem is, I have no idea where to even start. It seems that a license is created when the product is added to the cart, and the status of that license is changed when payment is confirmed.

Is the correct approach here to find the existing license when the product is added, then associate the existing license with the order? Is there an issue with that license then being associated with two orders?

Would we also need further logic when payment is confirmed to decide when the expiry date is, so to call renew() on the existing license with the purchased amount of time to add to the existing license.

Essentially I don't want any new license created at all and any guidance on where I should look would be very much appreciated.

💬 Support request
Status

Active

Version

1.3

Component

Documentation

Created by

🇬🇧United Kingdom darksnow

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