Subscriptions: How to implement beyond purchase?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
NC Software
AbleCommerce Partner
AbleCommerce Partner
Posts: 4620
Joined: Mon Sep 13, 2004 6:06 pm
Contact:

Subscriptions: How to implement beyond purchase?

Post by NC Software » Wed Jul 08, 2009 3:44 pm

I want to sell a subscription service which allows a person access to a specific web page on my AC 7 site. So the person obviously needs to login, when logged in I need to check when a person lands on the page if they have access (are they a member of the subscription group) and then a check to see if their subscription is valid. On top of that, this particular page (service) will have different options, i.e. "Subscription Plan - Tier 1, Tier 2, Tier 3". So depending on their Tier, different features become available on this service page.

Any tips on how to implement this? I searched the Docs, Wiki, Forums - no info on how to use Subscriptions beyond creating a product for them.

Thx
Neal Culiner
NC Software, Inc.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Subscriptions: How to implement beyond purchase?

Post by mazhar » Thu Jul 09, 2009 9:21 am

One solution could be to first setup a subscription product and creating a user group to represent the subscription users. Then you can put some code to automatically put the customer to that subscription group who purchases that subscription product. The next job as you said would be to put some code to the container which will show web page to take care of your requirements like user belongs to proper group and has valid subscription current context. If user weak in any area you can redirect him/her to some other public page for example default page. One more thing you may also need to work out something to relate webpages with subscription products because when trying to view a webpage you will need to check its associated subscription data.

How to automatically put user in some user group?
viewtopic.php?f=42&t=10791
viewtopic.php?f=42&t=9633
How to check user belongs to this group?
First find out the desired group id from ac_Groups table and then you can check it as

Code: Select all

if (!Token.Instance.User.IsInGroup(11)) //where 11 represents the subscription group id
{
//code here
}

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: Subscriptions: How to implement beyond purchase?

Post by Logan Rhodehamel » Thu Jul 09, 2009 10:11 am

NC Software wrote:Any tips on how to implement this? I searched the Docs, Wiki, Forums - no info on how to use Subscriptions beyond creating a product for them.
The documentation approaches them with a managed billing perspective... in other words they are simply markers for a recurring payment. However you may notice on the subscription page there is an ability to assign a group. Since this gets into custom code, I can't fully document it at this time. But here is a rough outline on creating and using custom permissions (roles). Perhaps Mazhar or other developers can look at this and flesh it out. It would make a good developer wiki.

1) Create a custom role (sounds like in your case three) in the ac_Roles table. There is no merchant interface to do this because I was not sure there would be interest in using it. Perhaps I will have this added to the admin.

2) Create custom group(s) and assign them to the role(s).

3) Create the product(s) and subscription plan(s) and assign to the group(s).

4) Create (or modify) the ASP script of the page you want to have respond to the permissions. Use the control LoginView to show content specific to a role. LoginView wraps around your custom content and can show/hide based on roles.

5) If the webpage should only be accessible to these roles and should force a login for other users, create (or modify) the web.config file. See Checkout/web.config for an example of targeting specific scripts for permissions. This uses standard ASPNET membership roles, so what you want to do is deny access to the page for everyone but your custom roles. Then ASPNET membership (used by AC) will do all the work for you.

Hope that gets you in the right direction. Note that when a subscription expires, the customer will be pulled out of the group.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

User avatar
NC Software
AbleCommerce Partner
AbleCommerce Partner
Posts: 4620
Joined: Mon Sep 13, 2004 6:06 pm
Contact:

Re: Subscriptions: How to implement beyond purchase?

Post by NC Software » Thu Jul 09, 2009 10:46 am

Thanks! I have a game plan and will proceed. I think this scenario will come about more than you think. In searching this forum I've seen other similar requirements. Sell a subscription that gives access to an area and also controls features, how many of X can you buy, use, download, upload, whatever.

I do think it would be valuable to add ROLES. I need them for my business to control what my subs can access in the Admin, and obviously as stated in my scenario for the subscription.

Off to implement....
Neal Culiner
NC Software, Inc.

amgym-jt
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 27
Joined: Mon Mar 17, 2008 12:35 pm

Re: Subscriptions: How to implement beyond purchase?

Post by amgym-jt » Sun Aug 23, 2009 11:28 am

I have a client that needs an almost identical implementation. Were you able to successfully achieve this inside of AC7? Here is what I need to do:

1. Create 3 different subscription plans (Service Plan 1, Service Plan 2, Service Plan 3). (this is straightforward in AC7)
2. When customer subscribes to a Service Plan, they are assigned a role corresponding to that plan (this is straightforward in AC7)
3. Customer then can access different areas of the web site according to the Service Plan they purchased. (not sure how to create the content that has restricted access for subscribers only)

Does anyone have a working solution for this? Thanks in advance for any help!

Post Reply