Subscriptions

Contrib type: 
Module
Status: 
Uploaded for testing

Downloads

Latest version: 
2008/04/11
Compatibility: 
Ubercart 1.x

uc_subscribe provides a framework for tracking and acting on subscriptions.

To get started using Subscriptions:

1. Check the admin settings:
/admin/store/subscriptions/settings

Set the 'Order status required for subscription registration' to a status at the point you want to grant the user the role change. If you set it to 'Pending', it will happen once the order is submitted. If you set it to 'Payment received', it will happen when the order's status is changed to that.

2. Check the actions page:
/admin/store/subscriptions/actions

You can configure some notifications and default actions here.

3. Add the 'Generic subscription' product feature to a product. Either configure a product attribute to define the contract length (so that the user can choose different lengths), or set a default value. The value or the attribute option names should be something like: '1 hour' or '30 days' or '5 months'.

4. Optionally, make a Workflow-ng configuration for changing the role of a subscription's customer when the subscription is registered, renewed, or expires.

Notes:

Recent development is moving away from using "Attributes to use as subscription period" and "Attributes to use as activation fee" in the site-wide admin options, and instead use the contract length setting in the
product feature options. (Activation fees are caught in the transition and not currently reliable.)

You can only use one attribute for the contract length of a given product. So, in the product feature options, select 'Product attribute' as 'Subscription length is defined by', and then selct either 'Yearly' or 'Monthly' under 'Product attribute for subscription length'.

The option for setting auto-renew is under the Store administration >> Subscriptions >> Actions.

Subscriptions are activated on each product with the required attribute in an order when the order first reaches a specified order status. Optionally, uc_subscribe can cancel a subscription when the order is cancelled.

uc_subscribe provides a hook (hook_product_subscribe) that enables modules to process four operations related to subscriptions: new registration, renewal, expiration, and when a subscription reaches its warning or notification threshold. uc_subscribe provides some basic actions for these events, including e-mail notifications and automatic renewals.

uc_subscribe also adds a 'Subscriptions' tab to the user's account page. This page allows users to renew subscriptions, as well as set options per subscription for receiving e-mail notices and automatically renewing the subscription.

uc_subscribe uses three methods for repeating an order when a subscription is renewed:

1. When an administrator selects 'reorder' on the subscription management page, a new order is created with the billing and delivery addresses and payment method from the previous order as well as the product being renewed.

2. If the customer clicks on 'renew', the product is added to the shopping cart and the customer is directed to the checkout page.

3. If the customer or administrator choose the setting to automatically renew products, the order is created similarly to the administrator's reorder function and the payment is processed. This provides a method for automatically recurring charges.

This module evolved from uc_expiry, coded by aymerick.

This module should be considered alpha. If you are interested in this module, please test it, and post your suggestions or contributions here.


PreviewAttachmentSize
uc_subscribe-20080411.tar.gz20.98 KB
torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Re: Subscriptions

Awesome! Can't wait to see this coupled with recurring payments. Nice work! Will be glad to help test.

--
Help directly fund development: Donate via PayPal!

giorgio79@drupal.org's picture
Offline
Joined: 02/02/2008
Juice: 280
Re: Re: Subscriptions

As per point 3 recurring payments is built in already...

3. If the customer or administrator choose the setting to automatically renew products, the order is created similarly to the administrator's reorder function and the payment is processed. This provides a method for automatically recurring charges.

ldway's picture
Offline
Joined: 02/26/2008
Juice: 27
Anything I should know before starting to test?

I just found this and it seems to be exactly what I have been looking for.

I am just downloading today to start testing. Is there anything I should know from others who have previously tested this module before I get started?

ldway's picture
Offline
Joined: 02/26/2008
Juice: 27
A Little Confused...

Well, I got the module running ok. However, I am a little confused on exactly how to get this setup with my subscriptions...

I have 2 membership subscriptions. Monthly and 1 Year.

Here is what I did so far: (Just guessing at what I am suppose to do)

1... admin/store/subscriptions - > I went into the settings tab and made a new attribute I called "1Year".

2... I setup my actions on the actions tab.

3... I went to the product and set it to the new attribute I created.

Not sure if this is the steps I was suppose to take or not... What shows up now above the Add To Cart button on the product is a text field with the label "1Year"... I assume I did something wrong or am missing exactly the correct steps as this seems pretty confusing to a customer who has no idea what if anything they are suppose to enter in the text field. (Nor do I have a clue)

Can anyone shine some light on exactly how to set this all up properly and use it? Really want to help test this but first I need to get a handle on the correct steps to set it up properly.

detour's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 10/02/2007
Juice: 151
Update

I just posted version 2008/04/04, which includes some major updates to the Subscriptions module:

-- I am transitioning from store-wide to per-product configurations for subscriptions. This version introduces a 'Generic Subscription' product feature. The contract length of a product can be set either to a fixed default value or to the value of a product's attribute.

-- I've also added Workflow-ng events for when a subscription is registered, renewed, expires, or reaches the notification threshold. Since Workflow-ng provides an action for changing a user's role, the Subscription module provides the functionality of uc_roles.

-- This version adds support for credit card encryption. If a subscription is purchased with a credit card, the customer can be charged automatically for renewals.

-- Contract lengths should be specified in natural language, like '1 day' or '4 weeks'. The following length units are available: second(s), minute(s), hour(s), day(s), week(s), month(s), year(s). If using attributes, the attribute name can be something like 'Contract length' and the option names should be like '30 days', etc.

I'll try to provide more documentation soon. I hope this update helps. Let me know how it works for you.

zcferres's picture
Offline
Joined: 04/06/2008
Juice: 55
paypal

It would be really nice to implement a feature allowing users to setup a recurring paypal payment with this. For a hosting company, users want to just draft their paypal accounts monthly without putting in more information. Using paypal recurring payments with this would be great. Until then, I have to stick with the recurring payments module.

duntuk's picture
Offline
Joined: 11/02/2007
Juice: 77
Re: Update

nice! this looks promising.

mrtoner's picture
Offline
Joined: 12/26/2007
Juice: 72
Re: paypal

"It would be really nice to implement a feature allowing users to setup a recurring paypal payment with this."

You'll be pleased to see that with the new uc_paypal_buttons module this is now not only possible, but easy.

http://www.ubercart.org/contrib/4218

ambereyes's picture
Offline
Bug Finder
Joined: 05/19/2008
Juice: 98
Subscriptions and anom

What would it take to allow subscriptions for anonymous users and then create a new account? I can throw some $$ toward a solution.

Katrina
--
www.ambereyes.net

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Re: Subscriptions and anom

I am testing this, and have Cron setup to run every hour. My subscription is supposed to be renewed 10 mins before its expiration... but it's not. I haven't dug into the code but how is this supposed to work? I imagine that Cron should be doing some checking but I only see expiration and notification functions there. If you need help getting the auto-renew feature working I'll be glad to contribute. This is a feature our site requires within the next month or so Smiling

--
Help directly fund development: Donate via PayPal!

fourcws's picture
Offline
Cool profile pic award.
Joined: 04/16/2008
Juice: 131
Re: Re: Subscriptions and anom

Hi targosPizza, How is it possible to have renewals at 10min before expire if cron is set to run hourly. I would think that cron would need to run every 9 minutes for this to work. Why would you need renewal control that close to expiration? Not criticizing, just curious about that.

dirkson's picture
Offline
Joined: 06/17/2008
Juice: 53
Re: Subscriptions

Quick request to update this to the Drupal6 ubercart. Otherwise, it looks like exactly what I need! Thank you!

qrios's picture
Offline
Cool profile pic award.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 554
Order duplication

Hi,

I discovered a problem with order duplication on reorder in uc_subscribe_reorder_subscription().

Some extra variables added by 3th party modules where missing. This was due to the fact that not the order object is duplicated, but only a strict set of object attributes are copied.

I solved it like this:

function uc_subscribe_reorder_subscription($sid, $process = FALSE) {
  $data = db_fetch_object(db_query('SELECT * FROM {uc_subscriptions} AS us JOIN {uc_order_products} AS uo ON (us.order_product_id = uo.order_product_id) WHERE sid = %d', $sid));
  if (!$data) {
    watchdog('uc_subscribe', t('uc_subscribe_reorder_subscription called with a subscription id (@sid) that is not registered.', array('@sid' => $sid)), WATCHDOG_ERROR);
    return false;
  }
 
  $order_product_id = $data->order_product_id;
  $order_id = $data->order_id;
  $order = uc_order_load($order_id);

  // automatically renew expiring items
  // create new order and duplicate delivery, billing, payment information
  $emptyorder = uc_order_new($data->uid, uc_order_state_default('in_checkout'));
  $neworder_id = $emptyorder->order_id;

  //Qrios hack
  $neworder = clone $order;
  $neworder->order_id = $emptyorder->order_id;
  unset ($neworder->line_items); //dont take line items from existing order
  unset ($neworder->products); //dont take products from existing order
 
  if ($order->payment_method=='credit') {
    $obj = db_fetch_object(db_query('SELECT * FROM {uc_payment_credit} WHERE order_id = %d', $order_id));
    $cc_key = uc_credit_encryption_key();
    if ($cc_key !== FALSE) {
      $crypt = new uc_encryption_class;
      $neworder->payment_details['cc_type'] = !empty($obj->cc_type) ? $crypt->decrypt($cc_key, $obj->cc_type) : '';
      $neworder->payment_details['cc_owner'] = !empty($obj->cc_owner) ? $crypt->decrypt($cc_key, $obj->cc_owner) : '';
      $neworder->payment_details['cc_number'] = !empty($obj->cc_number) ? $crypt->decrypt($cc_key, $obj->cc_number) : '';
      $neworder->payment_details['cc_exp_month'] = !empty($obj->cc_exp_month) ? $crypt->decrypt($cc_key, $obj->cc_exp_month) : '';
      $neworder->payment_details['cc_exp_year'] = !empty($obj->cc_exp_year) ? $crypt->decrypt($cc_key, $obj->cc_exp_year) : '';
      $neworder->payment_details['cc_cvv'] = !empty($obj->cc_cvv) ? $crypt->decrypt($cc_key, $obj->cc_cvv) : '';
      $neworder->payment_details['cc_bank'] = !empty($obj->cc_bank) ? $crypt->decrypt($cc_key, $obj->cc_bank) : '';
      uc_store_encryption_errors($crypt, 'uc_subscribe');
    }
    else {
      $neworder->payment_details['cc_type'] = $obj->cc_type;
      $neworder->payment_details['cc_owner'] = $obj->cc_owner;
      $neworder->payment_details['cc_number'] = $obj->cc_number;
      $neworder->payment_details['cc_exp_month'] = $obj->cc_exp_month;
      $neworder->payment_details['cc_exp_year'] = $obj->cc_exp_year;
      $neworder->payment_details['cc_cvv'] = $obj->cc_cvv;
      $neworder->payment_details['cc_bank'] = $obj->cc_bank;
    }
  }

  // add expiring items to new order
  $order_total = 0;
  foreach ($order->products as $prod) {
    if ($prod->order_product_id==$order_product_id) {
      $prod = uc_subscribe_remove_activation($prod, FALSE);
      $prod->order_product_id = 0;
      $prod->order_id = 0;
      $prod->data['subscription'] = $sid;
      $neworder->products[] = $prod;
      $order_total += $prod->price;
    }
  }
  $neworder->order_total = $order_total;

  // set the order modified time to prevent erasure of attributes
  $neworder->modified = time();
  uc_order_save($neworder);
       
  // complete sale of new order, moving order from in checkout to pending
  uc_cart_complete_sale($neworder);

  // process payment of new order
  if ($process) {
    if ($order->payment_method=='credit') {
      $neworder = uc_order_load($neworder_id);
      $res = uc_payment_process($neworder->payment_method, $neworder_id, uc_payment_balance($neworder), NULL, TRUE);
    }
  }

  // add comment to order
  uc_order_comment_save($neworder_id, 0, t('Order created as re-order.'), 'admin');
  uc_order_comment_save($neworder_id, 0, t('This is a repeating charge.'), 'user');

  return $neworder_id;
}

In short I duplicated the order object and deleted/altered only the necessary attributes.

In my case this is a fine solution.

Regards,

Kees

iajay's picture
Offline
Joined: 07/21/2008
Juice: 49
Product Kit

Does this support Product Kit also
I mean to say, can i add the subscription feature to a product kit instead of an individual product?
Ajay

marco's picture
Offline
Joined: 05/29/2008
Juice: 16
Re: Subscriptions

I keep getting the message 'This is your first subscription to this product. Please choose "New subscription" under "Activation fee".', when adding a product with generic subscription feature to cart. I checked everywhere but I haven't found where to set such option. In admin/store/subscriptions/settings, I have 'subscription term' attribute as subscription fee and subscription period. The options are 1 year / 2 year, and they have their related price.
If can help, in watchdog I read 'uc_subscribe_register_subscription called with an invalid duration for user Anonymous and order product id 21. Please check the attribute options for the attribute designated as contract length.'

Please advice.

Thanks,

marco.

marco's picture
Offline
Joined: 05/29/2008
Juice: 16
Re: Re: Subscriptions

I installed an old version of Ubercart (1.0), with the same configuration as above, and the problem disappeared.
Upgrading to Ubercart 1.3 doesn't recreate the issue. In short, it only appears on a fresh installation of Ubercart 1.3

islandpinnick@drupal.org's picture
Offline
Joined: 08/18/2008
Juice: 14
Automatic Renewal and PCI Compliance

Thanks so much! This is exactly what I need, How does automatic renewal work with PCI compliance? I see that it's storing the CC info in the database using encryption, but it looks like PCI does not allow the CVV to be stored, even if it's encrypted.
https://www.pcisecuritystandards.org/security_standards/download.html?id...

Any thoughts?

poppers's picture
Offline
Joined: 08/12/2008
Juice: 45
Re: Automatic Renewal and PCI Compliance

I installed this but I keep getting a text box rather than a drop down selector to control the subscription length. Also, the subscriptions Status is expired instantly.

I wish to be able to generate a 6 month product subscription where the subscription generates a new order with that product and charges the card automatically every month for 6 months. How would I do this?

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Re: Re: Automatic Renewal and PCI Compliance

The last two commenters should read the text files that come with the manuals. I'm pretty sure your questions are answered there.

@poppers: Quickly, the text box appears because you didn't add anything for Options. You need to create an Attribute (call it "subscription length" and then give it Options (1 month, 1 year, etc.).

@islandpinnick: The PCI Compliance I think will be fine as long as you use something like Authorize.net CIM where you are not storing any local data. If you read up on that I think it will make sense, let us know here if what you read does not agree with this concept.

--
Help directly fund development: Donate via PayPal!

islandpinnick@drupal.org's picture
Offline
Joined: 08/18/2008
Juice: 14
Re: Re: Re: Automatic Renewal and PCI Compliance

I've read the text files that came with this module. Are you referring to files in a different location as well? I agree that it is PCI compliant if you use CIM with Authorize.net, but I'm concerned with these lines of code:

  if ($order->payment_method=='credit') {
    $obj = db_fetch_object(db_query('SELECT * FROM {uc_payment_credit} WHERE order_id = %d', $order_id));
    $cc_key = uc_credit_encryption_key();
    if ($cc_key !== FALSE) {
      $crypt = new uc_encryption_class;
      $neworder->payment_details['cc_type'] = !empty($obj->cc_type) ? $crypt->decrypt($cc_key, $obj->cc_type) : '';
      $neworder->payment_details['cc_owner'] = !empty($obj->cc_owner) ? $crypt->decrypt($cc_key, $obj->cc_owner) : '';
      $neworder->payment_details['cc_number'] = !empty($obj->cc_number) ? $crypt->decrypt($cc_key, $obj->cc_number) : '';
      $neworder->payment_details['cc_exp_month'] = !empty($obj->cc_exp_month) ? $crypt->decrypt($cc_key, $obj->cc_exp_month) : '';
      $neworder->payment_details['cc_exp_year'] = !empty($obj->cc_exp_year) ? $crypt->decrypt($cc_key, $obj->cc_exp_year) : '';
      $neworder->payment_details['cc_cvv'] = !empty($obj->cc_cvv) ? $crypt->decrypt($cc_key, $obj->cc_cvv) : '';
      $neworder->payment_details['cc_bank'] = !empty($obj->cc_bank) ? $crypt->decrypt($cc_key, $obj->cc_bank) : '';
      uc_store_encryption_errors($crypt, 'uc_subscribe');
    }
    else {
      $neworder->payment_details['cc_type'] = $obj->cc_type;
      $neworder->payment_details['cc_owner'] = $obj->cc_owner;
      $neworder->payment_details['cc_number'] = $obj->cc_number;
      $neworder->payment_details['cc_exp_month'] = $obj->cc_exp_month;
      $neworder->payment_details['cc_exp_year'] = $obj->cc_exp_year;
      $neworder->payment_details['cc_cvv'] = $obj->cc_cvv;
      $neworder->payment_details['cc_bank'] = $obj->cc_bank;
    }
  }

This implies that this information is stored in the database. However, I haven't found anywhere that actually stores the info so I'm a bit confused here.

Thanks so much for your response.

islandpinnick@drupal.org's picture
Offline
Joined: 08/18/2008
Juice: 14
For anyone with this question/problem using PayPal

An FYI for all PayPal users that are looking to integrate with subscriptions. I found the best way to do this was to use PayPal's Reference Transaction. Instead of the code above, you look up the past transaction ID form the order history and send that to PayPal.

mr.andrey's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/12/2008
Juice: 153
Hello, We have multiple

Hello,

We have multiple video subscriptions with each having it's own corresponding role/permissions. I'm a bit unclear on how to make the expiration happen for the specific role.

-- For new product purchases --
event: new subscription
add condition: numeric comparison, [product:nid] = 99
add action: add user role (crib live)

-- For renewed subscriptions --
event: renew subscription
add condition: numeric comparison, [product:nid] = 99
add action: add user role (crib live)

What do I do for the expired subscription event if I want to expire the role that it enabled? How can I know which role it is tied into?

Thanks,
Andrey.

jasonruyle's picture
Offline
Joined: 01/18/2008
Juice: 238
Purchasing another subscription + to that period

I was wondering if anyone else noticed that if you have a user, lets say BOB, and bob orders a subscription for 1 unit every 30days. But if BOB wants to purchase another unit, the unit and its subscription is added to the current period and not stored for later.

Has anyone else had this issue?

asak@drupal.org's picture
Offline
Joined: 10/23/2008
Juice: 67
Any update on the PCI complliance issue?

Has anyone figured this out yet?

It's kinda importent... Eye-wink

jblank's picture
Offline
Joined: 08/25/2008
Juice: 56
Auto Renew

I have subscriptions setup and seemingly working. I created a test subscription that expires in 5 minutes and is set to renew automatically. However, after the initial subscription expired it just ended and did not renew automatically. I ran cron a few times and still nothing happened and a new order was not created.

Any help would be appreciated.

islandpinnick@drupal.org's picture
Offline
Joined: 08/18/2008
Juice: 14
A big little gotcha with cron

This one had me stumped for a bit. You'll notice that the cron works fine when you run it manually from the admin, but it doesn't renew when you're using something like crontab. If you check out the code that gets called when cron runs (sorry, can't remember where it is right now) you'll see that it checks to see if you're the admin user. However, when you run cron from crontab, you're likely running it as Anonymous so it doesn't renew. I removed the check for admin user and it worked for me.

ilakshmir's picture
Offline
Joined: 10/23/2008
Juice: 15
New version for Drupal 6?

This looks like a great module. Is there a plan to have a version of uc_subscribe for Drupal 6?

Sam_RiteTimeDirect's picture
Offline
Joined: 10/20/2008
Juice: 96
Subscription giving Activation Fee Error in UC 1.6

I am having the same issue as Marco with a new install of UC 1.6. Marco seemed to solve it by installing an older version of UC and updating. Is there any other way to deal with this? Is there a specific setting that I am missing?

Thanks,

Sam

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 302
Re: Subscription giving Activation Fee Error in UC 1.6

I'll have an update later this week fixing some issues.

Biodiesel * (ubercart + drupal) = Sundays Energy

ckidow's picture
Offline
Joined: 10/27/2008
Juice: 46
Compatiblity with uc_node_access

Does this module automaticaly act as a single checkout or does it only advise ubercart to do a payment?

I ask this because I enabled the node_access feature... so if the user choose a 3 month period he got access to the node for exact 3 months.

Sam_RiteTimeDirect's picture
Offline
Joined: 10/20/2008
Juice: 96
Update

Any word on that update?

Thanks in advance.

Sam

ryanschmidt's picture
Offline
Joined: 11/17/2008
Juice: 235
Any updates? Also, am I able

Any updates?

Also, am I able to use naming conventions like "Monthly" or "Annually"? "1 month" and "12 months" looks pretty silly.

crooke's picture
Offline
Joined: 03/15/2008
Juice: 77
'This is your first subscription to this product. Please choose

Hi,

this must be a great module and just what i need on my site!

I really don't know what i'm doing wrong though. I followed the readme and read this whole forum but still i get 'This is your first subscription to this product. Please choose "New subscription" under "Activation fee" message when trying to add a test product with subscription feature enabled. I created an attribute "Subscription" with options "3 months", "6 months", "1 year". I have enabled the subscription feature for the product and set the "Subscription length is defined by" and "Product attribute for subscription length" to my attribute. Still it displays the error message. When i set the "Subscription lenght is defined by" to "Default value" and type in say 1 hour i get the same error message.

Using:

D 5.14
UC 1.6

Any ideas are really welcome coz i'm scratching my head all day long! Smiling

Thanks!

Rob

crooke's picture
Offline
Joined: 03/15/2008
Juice: 77
Cron problems

@islandpinnick@d...: I would check my user table to make sure ID 0 is not missing. Some modules remove it from the database. If you don't have it just insert it in phpmyadmin and it should work fine.

Rob

magapp's picture
Offline
Joined: 12/29/2008
Juice: 4
Patch for Drupal 6.x

I've made a patch to make uc_subscribe compatible with Drupal 6.x.
It works for me, but I haven't tried all functionallity so please test it and post feedback.
Apply with: patch < uc_subscribe_drupal_6_x.patch

Why can't we put this module on drupal.org?

AttachmentSize
uc_subscribe_drupal_6_x.patch 33.13 KB
magapp's picture
Offline
Joined: 12/29/2008
Juice: 4
Patch for Drupal 6.x

Just noticed a minor mistake in the patch. In the uc_subscribe.install file, a new database schema is defined but is misspelled. Replace all 'uc_subscribe' with 'uc_subscription' and the initalization of the database should work better.

Sam_RiteTimeDirect's picture
Offline
Joined: 10/20/2008
Juice: 96
Any Plans on a 6.x Release?

Is it safe to give this a go or do I really need to wait for a release into 6.x?

Thanks

Eidolon Night's picture
Offline
Joined: 12/03/2008
Juice: 51
Patch not working?

I've applied the patch and made the changes noted for uc_subscribe.install, but Drupal still says "This version is incompatible with the 6.8 version of Drupal core." Am I missing something?

matsta's picture
Offline
Joined: 02/12/2009
Juice: 16
Subscriptions Drupal 6 Patch

Hi All,

I am newly converted to Ubercart from Drupal Ecommerce. This subscription module is exactly what I need and I am impressed with Ubercart. I am using Drupal 6.9 . I too have applied the patch for Drupal 6 and I can get it most of the way. However I think I am still having a problem with this ammendment from the post above:

"In the uc_subscribe.install file, a new database schema is defined but is misspelled. Replace all 'uc_subscribe' with 'uc_subscription'".

I do seem to have an issue here, if I make no additional changes to the patch from it's download I get the following error on the subscriptions-manage page.

user warning: Table 'neos_drplclas.uc_subscriptions' doesn't exist query: SELECT * FROM uc_subscriptions AS us JOIN uc_order_products AS uo ON (us.order_product_id = uo.order_product_id) ORDER BY texpire DESC in /home/neos/public_html/classifieds/sites/all/modules/uc_subscribe_6/uc_subscribe.module on line 1180.

When I then change references to 'uc_subscribe' with 'uc_subscription' I still get the same error, and I dont even get a table installed on the database. With just the patch I did get a table installed but I still had the same error above each time.

Looking at the code with my untrained eye I then tried using 'uc_subscriptions' instead in the .install file, still no change, and no table installed in the DB.

I have been uninstalling the module in between file changes.

The only other error I seem to get is the following on the modules page after installation:

warning: Invalid argument supplied for foreach() in /home/neos/public_html/classifieds/includes/common.inc on line 3286.
warning: Invalid argument supplied for foreach() in /home/neos/public_html/classifieds/includes/common.inc on line 3207.

I feel like I am close as the subscription admin pages are showing. I would happily upload my complete files for the module if I can get it working cleanly for D6.

Thanks,
Matt.

Docc's picture
Offline
Getting busy with the Ubercode.
Joined: 07/03/2008
Juice: 169
Re: Subscriptions Drupal 6 Patch

$schema['uc_subscribe'] on line 11 should be $schema['uc_subscriptions']
If you already had the module enabled, first uninstall it.

Regards

valentine2922's picture
Offline
Joined: 04/28/2009
Juice: 7
Modified patch

Corrected some errors in the patch that I could tell were wrong:

1. (line 47) changed to subscribe to subscriptions (this error has already been mentioned in these comments)

2. (line 54) changed int to uid (without this change the uid is not added to the table, and the subscription will not work)

Hopefully this module will work now. It seems to work, but I am going to keep testing.

AttachmentSize
uc_subscribe_drupal_6_x.patch 33.13 KB
matsta's picture
Offline
Joined: 02/12/2009
Juice: 16
Drupal 6 Patch

I am still having one problem with the D6 patch.

All seems to work up until setting the product feature options. Even though I have an attribute assigned for the product I then edit the generic subscription that has been created and I cannot get the drop-down to appear under the "Product attribute for subscription length". So I cannot select the "Product attribute" option to define my subscription length.

In my logs I get the message "uc_subscribe_register_subscription called with an invalid duration for user test and order product id 4. Please check the attribute options for the attribute designated as contract length."

It seeems to be related to this piece of code below. Can anyone shed any light on why this would not be working in D6?

-------------------------------------------------------------------

// get product attributes
$attropts = array();
$res = db_query('SELECT ua.* FROM {uc_attributes} ua JOIN {uc_product_attributes} upa ON (ua.aid = upa.aid) WHERE upa.nid = %d', $node->nid);
while ($obj = db_fetch_object($res)) {
if ($obj->aid && !empty($obj->name)) {
$attropts[$obj->aid] = $obj->name;
}
}

// build the form
$form['subscription'] = array(
'#type' => 'fieldset',
'#title' => t('Configure subscription settings for @title', array('@title' => $node->title)),
);
foreach ($sdata['attributes'] as $key => $title) {
$form['subscription']['attr-'. $key] = array(
'#type' => 'select',
'#title' => t('Please choose the attribute that designates @type', array('@type' => $title)),
'#options' => $attrs,
'#default_value' => $defattrs[$key],
);
}
$form['subscription']['length'] = array(
'#type' => 'fieldset',
'#title' => t('Subscription length settings'),
);
$form['subscription']['length']['length'] = array(
'#type' => 'radios',
'#title' => t('Subscription length is defined by'),
'#options' => array('attribute' => t('Product attribute'), 'value' => t('Default value')),
'#default_value' => isset($defattrs['length']) ? $defattrs['length'] : 'value',
);
if (count($attropts)) {
$form['subscription']['length']['lattr'] = array(
'#type' => 'select',
'#title' => t('Product attribute for subscription length'),
'#options' => $attropts,
'#default_value' => $defattrs['lattr'],
);
}
else {
$form['subscription']['length']['lattr'] = array(
'#type' => 'item',
'#title' => t('Product attribute for subscription length'),
'#value' => t('No attributes defined for this product.'),
);
}
$form['subscription']['length']['lvalue'] = array(
'#type' => 'textfield',
'#title' => t('Default value for subscription length'),
'#default_value' => $defattrs['lvalue'],
'#size' => 12,
);
$form['subscription']['length']['quantity'] = array(
'#type' => 'checkbox',
'#title' => t('Item quantity multiplies contract length'),
'#default_value' => $defattrs['quantity'],
);
/* TODO add activation fee settings
$form['subscription']['activation'] = array(
'#type' => 'fieldset',
'#title' => t('Activation fee settings'),
);
*/
$form['subscription']['subid'] = array(
'#type' => 'hidden',
'#value' => $module,
);
return uc_product_feature_form($form);
}

svc
svc's picture
Offline
Joined: 09/25/2008
Juice: 6
Anyone interested in contributing to a bounty

to get uc_subscribe tested and released for D6? I can really use a working release. Thanks.

reubidium@drupal.org's picture
Offline
Joined: 05/04/2009
Juice: 14
Stay tuned..

Bit by bit I'm getting this to work with D6. I'll post a patch when I've got it squared away.

One of the things I keep wondering about with this is why not use the Recurring Payments and Role Assign features that come with UC. Would appreciate if I could find some discussion on why go with one or the other.

thesaunterer's picture
Offline
Joined: 04/29/2009
Juice: 5
Why use Subscriptions

I looked into using role assignments for advertisers on my site, however, I'd like them to be able to add multiple listings and pay for each one separately. Roles makes that almost impossible. I thought about using node_checkout for this, but I need the listings to seamlessly upgrade/downgrade with different features. What I've ended up going with is subscriptions which, when bought give a user points in a table using actions. Then my node templates and hook_alters for that node type offer them the ability to create nodes with more or less features depending on their points usage. I'm working on getting the expiration all figured out, but subscriptions was really my only option for this. It would be nice if expiration could be set as a trigger!

Beaume's picture
Offline
Joined: 06/28/2009
Juice: 2
Any advance?

Hi,

Thats cleary what i need! Is there someone that can help me to put the patch into that module? I can open them but i have no clue to MERGE or update the first one with the patch...

The BEST would be to have a module that DIRECTLY work with Drupal 6 but while i wait i would use some tips! Smiling

Thanks

matsta's picture
Offline
Joined: 02/12/2009
Juice: 16
D6 Patch not complete

The current patch for D6 is a long way from being a working version. I have tested it extensively and there are a lot of issues.

There are also issues with the D5 version. I can get the D5 version to work by installing it on a very early release of Ubercart, and then upgrading to the latest release of Ubercart (this has been discussed in earlier posts above). If you install the D5 version directly on the latest version of Ubercart you will encounter problems. I have no idea why it works via an upgrade but it does.

Regarding the D6 version, my best results have then come from upgrading the 'upgraded D5 version' to D6 with the patched D6 module. If you install the patched D6 version on a new installation of D6 you get the same issues as using the latest version of Ubercart in D5.

Even then, the D6 version is incomplete. While I have finally been able to get a subscription to actually register in D6 (after also making a database modification that is not documented in the D6 patch) there is still issues with the end user management. I think I have the admin side mostly working, but end user cannot renew or manage their subscriptions.

I can go into a lot more detail on specific errors and provide my current files and so forth if anyone can help with creating a solid D6 version (and an updated release for D5 too for that matter). I cannot code PHP so cannot do it myself. However I do have a number of installations at different working points and I am willing to do as much testing and feedback as is necessary to assist.

stuboo's picture
Offline
Joined: 07/13/2009
Juice: 2
I'd throw in some coin for a bounty

to get uc_subscribe tested/released for D6.

amit's picture
Offline
Joined: 07/27/2009
Juice: 12
Membership renewal notification

I want my customer should received "Membership renewal notification". Let say website membership life is one year. Then before expiration he should received mail notification.
Let say he should received notification mail 1 day/ 5 days/ 10 days before the expiration date.

vood002's picture
Offline
Joined: 08/06/2009
Juice: 69
I can contribute

I would love to contribute to a bounty to get this module working for D6.