On our site, we want users to be able to have the choice of donating without buying any products. The Ubercart Donation Products module (http://drupal.org/project/uc_donation) provides this functionality, but its implementation of a donation checkout pane is currently very broken. As a result, we use Ubercart Add Donation instead, so that users that ARE buying products are reminded to donate at checkout.
Unfortunately, Ubercart Add Donation isn't currently aware of Ubercart Donation Products -- as a result, is possible to add a Donation Product to your cart, and then be prompted to donate again by Ubercart Add Donation.
By borrowing some code from the Ubercart Donation Products checkout pane, I've found a way to automatically hide the Ubercart Add Donation checkout pane whenever a Donation Product is in the cart:
Modify uc_add_donation.module as follows:
After:
function uc_add_donation_get_checkout_pane($op, &$arg1, $arg2) {
switch ($op) {
case 'view':
Add:
$cid = uc_cart_get_id();
$donations = FALSE;
$items = uc_cart_get_contents();
foreach ($items as $item) {
if ($item->module == 'uc_donation') {
$donations = TRUE;
}
}
if ($donations == FALSE) {
Then After:
// Return the checkout pane view.
return array('description' => $description, 'contents' => $contents);
break;
Add:
}
I've also attached a patch for this, though I'm not sure how to patch via the hosted Drupal code, so the patch was made locally.
It would be great if this could be implemented in a future release of Ubercart Add Donation.
| Comment | File | Size | Author |
|---|---|---|---|
| hide-checkout-pane.patch | 1.31 KB | TwistedLincoln |
Comments
Comment #1
TwistedLincoln commentedApparently the formatting was stripped from my post above, so be sure to look at the attached patch for the layout, otherwise it won't work properly...
Comment #2
travist commentedIs there anyway you can add this patch to the latest DEV? There were some changes brought in that seem to affect the same area of code.
I just want to make sure that it is right, and what better way to make sure than the person who is using that functionality.
Thanks!
Travis.
Comment #3
TwistedLincoln commentedSorry for the slow reply -- I wasn't subscribed.
The code I posted works fine with the 1.1 release -- I didn't try it with the DEV version, since you released 1.1 after you posted that message (and thus I assume 1.1 was the release made from the DEV you were speaking of).
Comment #4
travist commentedThis has been committed to the latest DEV release. Will be in version 1.2.
Thanks for your input.
Travis.