Discussions

Managing donations in Drupal Commerce

This question has come up quite a bit in IRC, e-mails, and the forum / issue queue. I want to just kickstart in this post a discussion that can result in one or more usable contributed modules for managing donations in Drupal Commerce.

When I think of a donation, I understand it as either a variable amount or some recommended amount of money given to an organization's general fund or dedicated to a specific initiative within that organization. On any given donation, then, you need to determine the amount from the customer, possibly get their designation, and then keep a nice tidy record of donations for end of year reports for both the donor and organization.

Often donations are the sole purpose of an e-commerce website, but they can also be collected on a site that sells other merchandise in a more traditional manner. This means a donation might be tacked onto another order, but donations might also all be handled through a standalone form that on one page allows the donor to designate an amount, fill in an address, provide payment details, and be done with a single click of the mouse.

The questions in integrating with Commerce revolve around how to get the designated amount, especially in cases where it's a free-form variable amount text field, and how to represent the donation on the order. I think these issues are connected, and I see two basic solutions off the top of my head:

  1. We can do like I did with UC Variable Price and create a donation "product" on the back end whose Add to Cart form includes an amount textfield. Upon submission, this amount would be stored in the product line item's data array. On subsequent loads of the shopping cart, this line item's unit price would always be set to the price value stored in the data array.
  2. Alternately we could create a donation line item type whose unit price isn't affected by the normal product pricing rules. In this case, the unit price would be set when the Add to Cart form is submitted, the line item would be added to the cart order, and its price wouldn't be changed (unless you built that ability into the cart form somehow or an administrator did it).

Either one of these things would be easily achievable in contrib.

Additionally, we'd want the ability to skip the cart and/or shorten the checkout process. If you are solely a donation site, you might get away with just creating a very simple form that accepts a donation amount, payment details, and submits by creating the order, adding the donation (or producT) line item, and being done. It really depends on your payment process... i.e. can you integrate the CC form into the donation form or do you have to redirect to PayPal and come back? I think most people will continue to need the Checkout form for payment reasons (and for combined donation / purchase orders), but that doesn't mean it can't be shortened / embedded on a donation specific page. The form isn't dependent on the checkout URLs, and it could be possible through some altering to change the checkout workflow to a single step submission when the form is embedded on a donation page.

The next question I'd have would be how to know where to embed the donation form. Any form ought to be standalone, able to function regardless of the display context. This is how Commerce entity forms work - the core order add / edit form makes no assumptions about URLs, redirects, etc. but is instantiated by the Order UI module to appear at a specific URL and redirect to another URL upon submission. If a custom donation form is treated the same way, it can then be made into a display formatter for the product reference field if you're using the product line item approach. It could be made into its own field if you're using the donation line item type approach and want to create a content type for unique donation pages. For either approach it might be enabled through some sort of Token that is replaced using a custom text format filter.

Really, this could go any number of ways, and ultimately it's going to depend on the various other business rules I've pointed out above:

  • Does the site just need to accept donations?
  • Does the site sell other products (i.e. swag, event registrations)? If so, does it support combined orders or would it still use a standalone donation form?
  • What payment method will be used and can its payment form be included inline in a standalone donation form?
  • How will the site report donations?
  • Where will donation pages fit in the IA for the site?

Ultimately, I think we'll want multiple solutions. Recreating UC Variable Price for DC wouldn't be that difficult, and I don't think creating a donation line item type would be that difficult but may come with unexpected side effects due to some dependence on product line items in the cart / checkout workflow (those can be addressed). The bigger question will likely be how exactly you want the donation form to be displayed, and anything is possible... using the cart / checkout form as is, embedding a trimmed down checkout form on the donation page, or creating a custom donation form that simply creates a new order upon successful payment completion.

What other ideas do we have? And who's up for developing some of this? ; )

Ryan Szrama
Posted: Mar 22, 2011

Comments

Ryan Ryan Szrama on March 23, 2011

Ahh, well, this isn't about getting donations for Drupal Commerce. Rather it's about how to use the Commerce modules to setup a donation site as typically required by a non-profit. Do you still think it's a useful discussion to cross post there?

sirspacey on May 27, 2011

My initial thought is you already provide the mechanism for controlling the steps in the checkout process, so this doesn't need to be a separate form. Perhaps we could provide a "template" donation form that replaces the steps currently set as the default when you install Drupal Commerce.

It seems like the 2nd option is cleaner, but from an Ubercart to Commerce migration perspective is UC Variable Price support necessary?

iainhallam on July 15, 2011

Another thing is to consider recurring donations. In my organisation, we'd like to accept a recurring donation (constrained to be more than a certain low amount, like £5/year) that will change your role to be a "Friend", with associated benefits.

This is pretty similar to a membership system, but has a user-selected price.

Another request is to allow someone to select not being added to the "Friends" list, and just make the recurring donation of the level they choose.

BMacKinney on October 29, 2011

Ryan,

I want to develop this module. I promise to follow the code workflow and best practices. This will be my first contrib to d.o. I'm going to need some guidance, but I'm willing to learn and I want to get these modules going for a site I'm working on.

Have you thought more about how this would look or how many modules we're talking about?

Brian

tmsimont on January 17, 2013

I developed a single page checkout process that uses Commerce Donate. I'd love to get some extra eyes on this and get some feedback. Let me know what you guys think.. I'm not sure how much more development I'll put into it, unless I see some interest generated. I have this running on a production site with PayPal WPP:
http://drupal.org/sandbox/tmsimont/1891418