In our previous blog post about ioby.org, the Social Microfunding website built in Drupal 7, we reviewed the high level goals of the project. Here, we are going to dive deeper into the technology that we used for the website.
One of the goals of the ioby project was to allow people to fund projects by donating to one or more projects through the website. For that piece of the application, we used the Drupal 7 Commerce module created by The Commerce Guys. For those of you new to the Commerce Guys work, you may recognize them as the creators of the ever popular UberCart system, which is the most popular shopping cart system on Drupal6.
New Features using Drupal 7 and Commerce
There are a few key parts of the application that we built for ioby that hadn’t been tried using Drupal 7 or, more importantly, Drupal Commerce previously. Because the site is donation centric and we want supporters to be able to donate an arbitrary amount of money to one or more projects, the first challenge was to make a product to place in the cart that didn’t have a set price associated with it. In order to do this, we create the product ‘on the fly’ as the donation is placed into the cart. The second challenge was to create a system that allows a user to also give a 20% gratuity directly to ioby so they are able to use the entirety of the donation to the project. The third challenge was to give the ability for corporations and sponsors to match the donation amount as part of a campaign for matching funds for a project.
The first challenge was handled by using a simple form that allows the user to enter the amount of the donation they want to give to a project. This form submit creates a new commerce product using the Entity API system. The product was created and customized with the donation amount, and then placed into the cart. Each product in the Commerce module requires a unique SKU, so we generate one based on the users name, the project title, and a date reference to assure no products are duplicated. Once created, the product is placed into the users cart, and the user is redirected to the cart page. One thing we uncovered is that the Commerce module is designed to set up the prices as an integer, instead of a decimal. This requires all prices to be converted back when placing data in or out of the database. This had us stumped for a little while, and fortunately the developers of the Commerce module were kind enough to assist us in the implementation of updates to resolve this issue.
For the third challenge – giving corporations and sponsors the ability to match the donation amount – we couldn’t just add line items to the donation like how user submitted donations are handled as this would change the donor information. Instead, we had to add a new panel to the checkout process that let the donator know that the sponsor was helping the cause as well. The sponsor was tied to the project by campaign node and using the new Drupal7 database API to make direct calls to the database and tie the sponsor, campaign, project and donation together. The beauty of the new database API is that it allows the developer to tie together a series of statements together to create a complex SQL statement, making maintenance and updates easier. Once the bond is created, a donation match is created and funds attributed to the project, without charging the donator more.
This was a challenging and fun project for us. New Signature was lucky to get to work directly with The Commerce Guys on some of the deep elements of the site, and their team was very accommodating with their support. We were able to launch this site on an accelerated time line, in conjunction with Earth Day 2011.