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.

CommentFileSizeAuthor
#3 subs5.png36.57 KBbjlewis2
#2 subs1.png24.34 KBbjlewis2
#2 subs2.png15.43 KBbjlewis2
#2 subs3.png26.2 KBbjlewis2
#2 subs4.png21.88 KBbjlewis2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bjlewis2’s picture

Status: Active » Closed (works as designed)

Figured it out, needed to create new subscription entity. Works now!

bjlewis2’s picture

Status: Closed (works as designed) » Active
FileSize
21.88 KB
26.2 KB
15.43 KB
24.34 KB

Ok, 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?

bjlewis2’s picture

FileSize
36.57 KB

I 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:

bjlewis2’s picture

double posted...

alexweber’s picture

Assigned: Unassigned » alexweber
Status: Active » Needs work

@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...

bjlewis2’s picture

Hey 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

alexweber’s picture

I'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 :(

alexweber’s picture

And again... :(

ddgza’s picture

I 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:

    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "subs",
            "param_type" : "three_month_subscription",
            "param_uid" : [ "commerce-order:owner" ],
            "param_status" : "0"
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity - 3MSUB" } }
        }
      },
      { "subs_active" : { "subscription" : [ "entity-created" ] } }
    ]