Users of my setup should be able to sign up for the same plans multiple times. When I click on Subscription > Add plan then the previously subscribed plan is not available for signing up again showing inactive "Selected" instead of active "Sign up" link.

Another way of subscribing to the same plans multiple times would be just changing the quantity for already signed up plans. So I made sure the "Multiple-plan mode" option is selected on admin/config/services/recurly. Also on Recurly UI I went to Configuration > Hosted Page Settings and made sure the "Editable Quantities" selected and that the "Allow customers to edit the plan quantity on the Hosted Payment Page." is checked on each of plans. However, users still can't change the quantity of already subscribed plan.

How would I go about this problem? Thanks!

Comments

nickonom created an issue. See original summary.

nickonom’s picture

Status: Active » Closed (duplicate)
Related issues: +#2025995: Change Quantity Module

I've found previously created request for this: #2025995: Change Quantity Module

nickonom’s picture

Status: Closed (duplicate) » Active

I have to re-open this one, because the subject matter of the other issue is different anyway. The other issue is about changing the number of order items (second paragraph of the initial report above), while this one is about inability to place new orders for the same products.

The current state which doesn't allow to subscribe to the items which had previously been ordered covers only some use cases when they sell one line recurring subscriptions with upgrade or downgrade options only.

However, consider a company that sells recurring services of different types and its customers should be able to subscribe for the same type of services multiple times. For example, a web-hosting company sells several types of plans. First, its customer subscribes to one of the plans to host her website. Later she decided to host another website and she wants it to have its own isolated hosting account of the exactly the same type. And she won't be able to do so if Recurly module with current state is used.

So I strongly believe that anything pertaining to previously placed orders (actions like upgrade/downgrade/change number of subscribed items) should be dealt on the user/%/subscription/list page. None of the previously placed orders should anyhow effect and limit future orders, so all products on the user/%/subscription/signup page should be always available. Thus then all possible use cases will be covered.

nickonom’s picture

And here is a simple patch that removes the following part from the includes/recurly.pages.inc b/includes/recurly.pages.inc file.

 // If we have a pending subscription, make that its shown as selected rather
    // than the current active subscription. This should allow users to switch
    // back to a previous plan after making a pending switch to another one.
    foreach ($subscriptions as $subscription) {
      if (!empty($subscription->pending_subscription)) {
        if ($subscription->pending_subscription->plan->plan_code === $plan_code) {
          $variables['filtered_plans'][$plan_code]['selected'] = TRUE;
        }
      }
      elseif ($subscription->plan->plan_code === $plan_code) {
        $variables['filtered_plans'][$plan_code]['selected'] = FALSE;
      }
    }

That part was really unnecessary as, again, everything pertaining existing orders should be dealt on their own pages and should not effect new orders.

nickonom’s picture

Status: Active » Needs review
nickonom’s picture

Sorry, but previous patch was not clean, please review this one.

markdorison’s picture

Status: Needs review » Needs work

@nickonom I understand the use case that you are describing and I think it is worthwhile to support it, but we need to be able to support the existing functionality as well. I have not looked at this part of the code recently, but I am skeptical that just removing that one block of code that is related to displaying the state of subscriptions will be sufficient. There is most likely code elsewhere that makes assumptions when there is an active subscription that we would need to be cleaned up. If you have already investigated this, please fill me in.

everything pertaining existing orders should be dealt on their own pages and should not effect new orders.

Can you go into further detail on this proposal? It sounds like it may be a pretty big UX change. If we want to go down that road I think we should look at some rough wireframes of the new user flow that is being proposed as it compares to the current one.

nickonom’s picture

Well, I did throughly test the functionality on UI and everything works as expected. I didn't explore code-wise assuming that active subscriptions and all the possible actions with active subscriptions still hold for our use case. The removed part just prevents to subscribe for the same plan on UI level and nothing more. So the rest of the code which concerns any change for the active subscriptions must be kept.

I understand there are use cases for the current state, when there should be no more subscriptions for the same product/plan, however:

(1) I firmly believe those are really rare cases and that the number of commerce projects that need to provide unlimited subscriptions significantly prevail;

(2) it is quite logical and intuitive for most use cases to operate active subscriptions without effecting the future subscriptions. I mean active subscriptions should be upgraded/downgraded/changed/modified on their own pages to which users could go from the page that lists active subscriptions.

Just think: you already have subscriptions, so they are already in the system and should be dealt behind the curtain - both admins and users have their profile account to operate with active subscriptions on "back-end" side. At the same time subscription page is kind of "front-end" for both new and existing users, because they want to subscribe for the new services on this page. And it is really strange to apply any kind of limitations on the subscription page.

(3) However if both (1) and (2) are not convincing to you then let's add another options on the admin/config/services/recurly page next to:

 Single-plan mode
 Multiple-plan mode

options. Though it is already confusing, because I thought that the current state should be covered by first options "Single-plan mode" and the use case that I am trying to get implemented here - by the second option " Multiple-plan mode". Unfortunately, it is not - despite the following description:

Single-plan mode allows users are only one subscription at a time, preventing them from having multiple plans active at the same time. If users are allowed to sign up for more than one subscription, use Multiple-plan mode.

selecting the second option does not unblock the plans to which a user had already been subscribed, so if s/he wants to get exactly the same product again, then s/he simply have no such option.

So if you believe the above two options are valid and each of them is working as expected, then here is my request to add a third option - not to limit anything on the subscription page.

markdorison’s picture

Title: Allowing end users to subscribe for the same plan multiple times » Allow users to subscribe to a single plan multiple times
Category: Support request » Feature request

(1) I firmly believe those are really rare cases and that the number of commerce projects that need to provide unlimited subscriptions significantly prevail;

And it is really strange to apply any kind of limitations on the subscription page.

I don't doubt that there are many use cases where this is needed. I would encourage you to not assume too much about use cases you personally have not encountered.

Through it is already confusing, because I through that the current state should be covered by first options "Single-plan mode" and the use case that I am trying to get implemented here - by the second option " Multiple-plan mode".

As you point out above the module does currently support users signing up for multiple plans. What it does not support is users signing up for multiple subscriptions of a single plan which is what we are discussing here.

I think at the very least we need to create this as a configuration option that can be enabled. Users currently using this module should not suddenly have their functionality changed without opting in.

nickonom’s picture

I don't doubt that there are many use cases where this is needed. I would encourage you to not assume too much about use cases you personally have not encountered.

That's true and I just believe that the most cases should be set by default and the less frequently used cases should be available as options. In that sense the stats play some role.

I think at the very least we need to create this as a configuration option that can be enabled. Users currently using this module should not suddenly have their functionality changed without opting in.

Totally agree with you.

nickonom’s picture

Status: Needs work » Needs review
StatusFileSize
new2.95 KB

How about this one, which adds a new mode option on admin page and preserves checks for two existing modes?

Please note that the includes/recurly.admin.inc had the reversed ordering for mode selection like this:

      '1' => t('Single-plan mode'),
      '0' => t('Multiple-plan mode'),

and since I didn't want to impose the new mode putting it on top (that's for the module maintainers to consider) I had to add it like this:

      '1' => t('Single-plan mode'),
      '0' => t('Multiple-plan mode'),
      '2' => t('Multiple-subscriptions mode'),

So everything works just as before and the only difference is that if the new mode selected then the subscription page makes all plans always available.

nickonom’s picture

Sorry for the wrong patch, please review this one.

nickonom’s picture

It's a shame I totally missed another place where changes needed to be done. To say frankly these are my ever first patches, so please bear with me.

Here is another patch and this time I tested really well putting the site into different modes and everything works as expected.

markdorison’s picture

Status: Needs review » Needs work
  1. +++ b/includes/recurly.admin.inc
    @@ -258,8 +258,9 @@ function recurly_settings_form($form, &$form_state) {
    +      '2' => t('Multiple-subscriptions mode'),
    

    I think this should not be a part of the recurly_subscription_max setting. It should be in it's own setting, recurly_subscription_multiple or similar. Just because someone wants to enable users to subscribe to a plan multiple times, doesn't mean they don't also want to allow subscriptions to multiple different plans. Once this change is made, the logic below will need to be refactored.

  2. +++ b/includes/recurly.pages.inc
    @@ -443,19 +443,22 @@ function template_preprocess_recurly_subscription_plan_select(&$variables) {
    +    // If Multiple-subscriptions mode selected, do not run checks ¶
    

    Trailing whitespace should be removed.

nickonom’s picture

I see what you mean. I will see if I can make needed changes.

nickonom’s picture

I wanted to work a bit on this today and have decoupled the new options into its own setting in recurly.admin.inc file like so:

  $form['pages']['recurly_subscription_multiple'] = array(
    '#title' => t('Multiple subscriptions'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('recurly_subscription_multiple', '1'),
    '#description' => t('If users are allowed to subscribe to a single plan multiple times, use Multiple-subscriptions mode.'),
    '#states' => $pages_enabled,
  );

And to refactor the template_preprocess_recurly_subscription_plan_select() I wanted to use:

 if (variable_get('recurly_subscription_multiple', '0')) {
   do something;
 } else {  do something; }

but am hitting the wall with what function's logic must be.

You see any of the Single-plan mode or Multiple-plan mode is limiting the https://domain.com/user/%/subscription/signup page and with any of them Multiple subscriptions for the same plan wont' work. So we have to exclude both of them for the Multiple subscriptions to be able to work.

To conclude, the initial proposal is working just as expected, but please enlighten me here if you want this work otherwise.

colan’s picture

eojthebrave’s picture

Status: Needs work » Closed (duplicate)

This feature, allowing users to subscribe to the same plan more than once, or $subscription->quantity > 1 was added in #2025995: Change Quantity Module to the 4.x branch. There's also a patch in that issue for the Drupal 7 branch, it's old, but I do know it still works because we've been using it for years on Drupalize.Me. It would need a little updating to match what's in the 4.x branch of the module, but if someone still needs it and wants to take that on I'm open to reviewing and helping out with it.