Setting up a subscription site with Drupal and Ubercart in 15 minutes
I planned on just giving a high level overview of how I typically go about setting up a subscription based Drupal 6 website. I planned on just creating a primer for someone to look over, but I decided to give myself a challenge and see if I can create the entire site in 15 minutes.
Another thing to note is that I will start from nothing and build a simple subscription site in Drupal in 15 minutes with just the default Garland theme. I will also be writing this blog post at the same time with all the commands or actions I perform on the site. I am not sure if I will get it finished in 15 minutes, but I guess we will see.
Outline
Before we start I am going to lay out the road-map I am going to follow when building this very minimal subscription site. Like I said, this won't be fancy, but it will work.
| Step | Est. Time |
|---|---|
| Create a fresh Drupal site with Aegir | 2 min |
| Download/Install needed modules using drush | 3 min |
| Configure Ubercart and payment gateway settings | 5 min |
| Set up the site roles | 1 min |
| Configure a simple subscription | 3 min |
| Frantically scramble to make it usable | 1 min |
Note: (last one before I start) Currently you will have to make a decision. If you want to use the included subscription module that comes with Ubercart Recurring, you will either need to apply a patch to Ubercart 6.x-2.4 version or just install the latest dev release of the module. More information on the patch route can be found in the README of the Ubercart Recurring module, but if your looking for the easy route, just download the latest dev release.
OK. Got my stopwatch... ready, set GO!
Create Drupal 6 site
OK set up a site called subscription.codekarate.com. Just waiting for the site to be created. Its on my dev environment so I need to add it to my hosts file.
Created site, logged in, changed admin username and password.
Time: 2:02
Modules
drush dl token pathauto uc_recurring
drush dl ubercart-6.x-2.x-dev
Now going to admin -> build -> modules to turn on the needed modules
- Pathauto
- Token
- Cart
- Conditional Actions
- Order
- Store
- Attribute
- Payment
- Roles
- Credit Card
- Test Gateway
- Recurring - Hosted Gateways
- Recurring Payments API
- Recurring Product Fees
- Subscription Manager
Ran into a tiny snag, took longer then expected.
Time: 8:45
Configure
Set up credit card encryption by creating a directory on my server outside the Drupal root. Was going to configure some other store settings but since I am behind I am going to skip it for now.
Time: 13:05
Site Roles
Admin -> Roles -> Created a site role called subscriber
At this point you would want to give this user extra permissions for subscribing to the site. I don't have any extra permissions yet so I am going to call this good.
Time: 14:15
Subscription
Admin -> Subscription Manager
- Click Create Subscription
- Give it a title and description
- Add a payment option, I set 1 month, $5, and unlimited billing cycle
- Add roles, clicked subscriber to add on purchase then "ctrl" clicked on subscribe for revoked when a subscription ends
- Save
Time: 16:10
Scramble
Now a quick test. Clicked on the title of the subscription in the subscription manager to get to the node page for the subscription. I edited it and added a menu item so I can get to it.
Now the link is there and I am ready to go. Purchase the subscription by adding it to my cart, proceeded to the checkout page, filled in my info, grabbed a test credit card number that I use for testing purposes, reviewed my order and finished my checkout.
Now if I go to "My Account" and recurring fees I can see that I have a $5 monthly recurring fee. Also you will notice that your user now has the "subscriber" role.
Time: 20:00
After notes
Wow... So I didn't make it in 15 minutes... maybe that was a little too ambitious. If I did it again and followed the same steps I am sure I could do it much faster.
There are still some things to note. First right now it is just set up to use the test gateway. This means that it is not completely functional yet. You will need to set up either Paypal or Authorize.net to get it completely working. Since this is just an example I didn't go through setting up the gateway. Setting up Authorize.net for recurring payments is relatively easy once you get the API keys. I have not had a lot of experience setting up Paypal but I am guessing it is fairly similar. The Ubercart recurring page has information about which gateways work with the modules.
Drupal makes building a simple subscription site quick and easy, however it is possible to extend this with some more time (and maybe some more modules) to make it very powerful and flexible. So if you want to provide a way for users to subscribe to specific sections of your site, content on your site, or services your site provides, you should be able to build it now.
This was thrown together very quickly so let me know if you run into any problems or have any extra suggestions. The test site I created is not live, so if you try to get to it, it will not work.



Discussions
Nice !
Just what I was looking for :-) Er, why did you use Drupal 6 and not 7 ?
Drupal 6 vs. Drupal 7
Drupal 6 still has the greatest amount of module support. Drupal 7 is still catching up in terms of available modules and support for those modules. My rule of thumb when building new sites right now, is this. Any large websites with many modules and lots of functionality are built using Drupal 6. Any websites with less modules and less functionality are built using Drupal 7. As time goes on, I will begin building less and less sites with Drupal 6 and move more exclusively to Drupal 7, however the contributed landscape is not quite mature enough yet.
Drupal 7
Would you be able to post the steps for Drupal 7? It would be a great help to those of us who are new to this.
Will try
I have not done it yet in Drupal 7 but will try to carve out some time to try it out and post my findings. Might take me a little while till I can get to it but I will see what I can do.
this looks good, have you
this looks good, have you done drupal 7 version yet? do you know if it is possible to set up hourly subscription interval as alternative to day/month/year?
Not yet
I have not had time to get around to a Drupal 7 version. I don't believe you can set up an hourly subscription interval out of the box, however with some custom coding you should be able to add that functionality to the recurring payments module.
Depending on how you set it up, it can be configured to run off Drupal's cron. You can modify the recurring payments form to allow the configuration of hours to get half the way there. Then you would probably need to modify the processing that occurs during hook_cron() to ensure that it recognizes the hourly recurring requirements.
Hopefully that helps you get started.
many thanks i will have a
many thanks i will have a go...
Great Post
Thanks for posting this.
I've been looking to set up a subscription based site and this is by far the best short, sweet and to the point overview of it I've found.
Thanks again!
Drupal 7
Can you give advice on building this same site using Drupal 7 and ZenCart? Please :)
Unfamiliar with ZenCart
I do not have any experience using ZenCart. I did some quick looking around and I stumbled upon this http://stackoverflow.com/questions/7383232/drupal-7-zen-cart. Is there a reason you need to use ZenCart? It looks like what you want to do might require some significant coding/development effort.
I am on siteground and they
I am on siteground and they do not offer ubercart. They offer:
XCart
CSCart
CreLoaded
Magento
PrestaShop
CubeCart
OS Commerce
Zen Cart
The project I have in mind is kind of like a job board. One type of member posts a job, another posts their skills. I'd like to charge one of the parties or both a small fee for the service.
I have no experience and no one to help me. If you have any suggestions I would greatly appreciate it. Feel free to write to me via my email and I will give more details if you'd like.
Thank you!
Siteground
I found this from the Siteground website which may help.
http://www.siteground.com/ubercart-hosting.htm
It seems that siteground supports both Drupal and Ubercart hosting (which you will need to set up a subscription site). Ubercart is simply a module that can be added on top of the Drupal platform to provide E-commerce functionality.
If you are just getting started with Drupal, I would suggest reading my recent post on Learning Drupal. It has a lot of resources and links to help you get started.
Thank you so much. You are a
Thank you so much. You are a great help!
Select subscription time during checkout
Hi..many thanks for the tutorial.
I have one query.I am trying to set up the site where users can select the time period for their checkout.How do i do it in ubercart.
many thanks
smtih
Clarification
Can you explain more about what you are trying to accomplish? Are you saying that you want to have a user checkout and specify when they want their payment to go through?
RE : Modules
Some of those module titles listed are little ambiguous. Would you mind linking to the project pages because I have found multiple "Conditional Actions" modules for Drupal 6.... is it UC Catalog Conditional Actions? What about the "Roles" module.... I have not found anything on drupal.org called "Roles".
Oh.....duh.....they all come
Oh.....duh.....they all come with ubercart. my bad. Sorry I have been working non-stop for 8 hours and it makes my reading comprehension suffer a bit. Excellent post!
Paid membership
Helo there,
great tut. I want to make a membership in ubercart where the user pay me with bank transfer and i activate their account for a certain period of time, depending on how much they paid. For example, if one day membership is $0.5 and the user paied $50, then i will be able to activate his account for 100days.
Is there a way to do that? I hope i make sense in what i asked!
Thank you in advance!
Post new comment