Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey,
I'm trying to create a rule so that when a particular product is purchased (using Drupal Commerce), a subscription is created for the order owner.
When I try to add the action, I don't see the option to create a new subscription, and can't figure out what action I need to add. All I see under subscription is:
- Cancel
- Change to grace period
- Expire
- Make active
- Make pending
- Renew
I tried adding the Make Active action, but couldn't figure out how to use that to create a subscription for the order owner.
Any thoughts?
P.S. I'm trying to accomplish something like this but, instead of granting a role, I'd like to create a subscription.
Comments
Comment #1
bjlewis2 CreditAttribution: bjlewis2 commentedFigured it out, needed to create new subscription entity. Works now!
Comment #2
bjlewis2 CreditAttribution: bjlewis2 commentedOk, so I was able to purchase a subscription, and was granted access to the premium content. However, it's created without a start or end date.
When I click "edit", I don't have the ability to set a start or end date.
But when I click "save subscription", it sets the start date to Wed, 12/31/1969 - 1800, with no end date.
Finally when I click edit one more time, I'm able to set an end date.
Do you know how I can have it automatically set the start date to the date/time of purchase? and also set the end date to correspond with the appropriate number of days based on the subscription type?
Comment #3
bjlewis2 CreditAttribution: bjlewis2 commentedI thought I'd try setting the date to "today", but trying to set the start date using "set a data value" gives the following error:
Comment #4
bjlewis2 CreditAttribution: bjlewis2 commenteddouble posted...
Comment #5
alexweber CreditAttribution: alexweber commented@bjlewis2 thanks for the report and apologies for taking so long to get back on this.
I'm going to try and replicate this from your steps (thanks for the images!) and I'll take it from there...
Comment #6
bjlewis2 CreditAttribution: bjlewis2 commentedHey Alex,
I was wondering if you've put any more thought into this. It's really the only thing holding me back from implementing Subs on ModulesUnraveled.com.
I need to be able to automatically create subscriptions when one is purchased. It's not really acceptable for someone to purchase a subscription then have to wait on my lazy behind to get around to creating the subscription manually. :D
Comment #7
alexweber CreditAttribution: alexweber commentedI'll try to get some work in this weekend, its been hectic getting back to work and I regrettably haven't had much time for contribs :(
Comment #8
alexweber CreditAttribution: alexweber commentedAnd again... :(
Comment #9
ddgza CreditAttribution: ddgza commentedI ran into this same problem but have figured out a work around.
In your Subscription Types make sure your default status is set to "Pending".
Then use "Create Entity" in rules to create your new subscription, make sure you set its status to "Pending"
Add the "Make a subscription active" action for the newly created entity and now you have start and end dates set for your subscription.
Here is the "Do" part of my rule for reference: