I don't have the ability to do this so I'm asking someone to help in the knowledge that any assistance goes to help disaster victims worldwide.

I have done a site for a charity that ships aid out to disaster victims worldwide. I have just about finished the donations cart using e-commerce but I need to add a check box so that the donor can indicate that they agree to let the charity reclaim the tax to increase the value of the donation. http://www.hmrc.gov.uk/charities/gift-aid.htm

So basically its a check box where the donor accepts a declaration it is a gift aid donation and that they have paid UK tax – to cover the tax the charity will reclaim. This can then appear on the invoice/e-commerce back end as a gift aid yes/no flag.

Comments

Redsmartie’s picture

I've sorted this in a round about way.

I've created a new product called "Gift Aid" and added the following to the donation items description:

<b>You can help us more by adding Gift Aid to your cart before you checkout</b>

<b><a href="http://www.mysite.com/?q=cart/add/25&destination=node%2F22">Click here to add Gift Aid now</a></b> or <a href="http://www.mysite.com/?q=node/25">Click here to find out more</a>

Where 25 is the gift aid and 22 is the donation

You can click on the add gift aid link and you get a message that you have added it to the cart without leaving the donation page.

If you go to the gift aid product you can get full details which I have entered as

Using Gift Aid means that for every pound you give, Our charity will receive an extra 28 pence from the Inland Revenue, helping your donation go further.
This means that £10 can be turned into £12.80 just so long as donations are made through Gift Aid. Imagine what a difference that could make, and it doesn’t cost you a thing.
By adding this to your cart alongside your donation you make a declaration that you would like to use Gift Aid.

pobster’s picture

Seeing as you're a charity, here's a freebie - add it to the bottom of your donate module;

function donate_menu($may_cache) {
  $items  = array();
  $access = user_access('administer store');

  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/store/settings/donate',
      'title' => 'donate',
      'callback' => 'donate_settings',
      'access' => $access,
      'type' => MENU_NORMAL_ITEM,
    );
  }
  return $items;
}

function donate_settings() {
  drupal_set_title('Donate module settings');
  $form['donate_gift_aid_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Gift Aid text'),
    '#default_value' => variable_get('donate_gift_aid_text', ''),
    '#description' => t('Enter descriptive text to be displayed beneath gift aid checkbox.'),
  );
  return system_settings_form('donate_settings', $form);
}

function donate_checkoutapi(&$txn, $op, $arg3 = NULL, $arg4 = NULL) {
  if ($txn == 'donate' && $op == 'review') {
    return 'donate';
  }

  if (is_array($txn)) {
    // Check to see if we have a donation in the cart
    foreach ($txn->items as $no => $key) {
      if ($key->ptype == 'donate') {
        $display = TRUE;
      }
    }
    if (!$display) {
      return;
    }
  }

  switch ($op) {
    case 'review':
      $form['donate_gift_aid'] = array(
        '#type' => 'item',
        '#description' => variable_get('donate_gift_aid_text', ''),
      );
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => $txn->misc['gift_aid'] ? t('Remove') : t('Add'),
      );
      return $form;
      break;
    case 'review_submit':
      if ($_POST['op'] == 'Add') {
        $misc = new StdClass;
        $misc->type = 'donate';
        $misc->description = 'Gift Aid';
        $txn->misc['gift_aid'] = $misc;
      }
      elseif ($_POST['op'] == 'Remove') {
        foreach ($txn->misc as $no => $key) {
          if ($key->type == 'donate') {
            unset($txn->misc[$no]);
          }
        }
      }
      elseif ($_POST['op'] == 'Place your order') {
        // Do nothing...  Was a breakpoint for testing
      }
      break;
  }
}

function theme_donate_review_form($form) {
  $output.= '<div class="container-inline">';
  $output.= form_render($form);
  $output.= '</div>';
  return theme('box', t('Include Gift Aid?'), $output);
}

Obviously you need to set up the help text in admin/store/settings/donate.

Pobster

Redsmartie’s picture

Thanks.

I'll give that a go.

Redsmartie’s picture

Just a few of questions.

How should I add it. At face value I just pasted the code below the existing in donate.module and it killed the site.

Where is I couldn't find this. Or does the above have to be in place too?

Lastly in addition to the variable donation, I have a single fixed price donation as a non-shippable product. Can this be used on that in any way.

If your initial kind gesture is turning out to be a bit of a larger job than intended let me know as the original solution is workable, don't feel obliged if you know what I mean :)

pobster’s picture

Don't include the tags... That's all... Sorry just assumed that'd be obvious!

How is your fixed price donation set up? Is it as a 'donation' or as a 'non-shippable' product?

edit: oh wait... yeah you said that already - well, nope it won't work then.

Pobster

Redsmartie’s picture

Sorry.. I'm not good with code :)

I'll take a look at it but I really need uniformity between the fixed donation and my set price £250 donation which allows the charity to provide a specific service.

pobster’s picture

Meh well it doesn't do anything particularly flashy, you could always alter the code here;

  if (is_array($txn)) {
    // Check to see if we have a donation in the cart
    foreach ($txn->items as $no => $key) {
      if ($key->ptype == 'donate') {  // here!!!
        $display = TRUE;
      }
    }
    if (!$display) {
      return;
    }
  }

I don't know what the type is for non-shippable products, but whatever it is you'd just add it like this:

     if ($key->ptype == 'donate' || $key->ptype == 'non-shippable') {

Then it'll display for both.

By the way, this isn't guesswork this code, it's something I wrote for a charitable site - so it does indeed work just fine! :o)

Pobster

Redsmartie’s picture

I'll have a play as I have a few days grace while I'm waiting for the worldpay account to go live.

Thanks again

edit: One more thing. In what form is the record that they declared the donation as gift aid. We have to keep permanent records for the tax man.

pobster’s picture

It appears on the invoice in the transaction list (under print invoice) - which is handy ;o) Else, I could always write a short bit of code to stick all the transactions up on a page? Wouldn't take long to do?

Pobster

Redsmartie’s picture

I'm just trying to get the donations mod working first.

I've removed the

<?php
?>

but nothings changed on my donation page

Also what do you mean by "you need to set up the help text in admin/store/settings/donate"

Is this a settings page in admin or a path in my installation? I don't have either.

What am I missing? I did mention I don't code didn't I ? ;)

pobster’s picture

Gah! My bad, didn't notice you're using Drupal 5.x, use this instead;

function donate_menu($may_cache) {
  $items  = array();
  $access = user_access('administer store');

  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/ecsettings/donate',
      'title' => 'donate',
      'callback' => 'drupal_get_form',
      'callback arguments' => array('donate_settings'),
      'access' => $access,
      'type' => MENU_NORMAL_ITEM,
    );
  }
  return $items;
}

function donate_settings() {
  drupal_set_title('Donate module settings');
  $form['donate_gift_aid_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Gift Aid text'),
    '#default_value' => variable_get('donate_gift_aid_text', ''),
    '#description' => t('Enter descriptive text to be displayed beneath gift aid checkbox.'),
  );
  return system_settings_form($form);
}

//...rest is the same...  Other than form_render is now drupal_render near the bottom like this;

function theme_donate_review_form($form) {
  $output.= '<div class="container-inline">';
  $output.= drupal_render($form);
  $output.= '</div>';
  return theme('box', t('Include Gift Aid?'), $output);
}

If you go into the ecommerce settings you'll see a new entry for donate (if you don't then flush/ empty your cache) where you can set some help text to let donaters know what Gift Aid is. The Gift Aid part doesn't come into it until you checkout (near the end).

Pobster

Redsmartie’s picture

So I've entered

function donate_menu($may_cache) {
  $items  = array();
  $access = user_access('administer store');

  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/ecsettings/donate',
      'title' => 'donate',
      'callback' => 'drupal_get_form',
      'callback arguments' => array('donate_settings'),
      'access' => $access,
      'type' => MENU_NORMAL_ITEM,
    );
  }
  return $items;
}

function donate_settings() {
  drupal_set_title('Donate module settings');
  $form['donate_gift_aid_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Gift Aid text'),
    '#default_value' => variable_get('donate_gift_aid_text', ''),
    '#description' => t('Enter descriptive text to be displayed beneath gift aid checkbox.'),
  );
  return system_settings_form($form);
}

function donate_checkoutapi(&$txn, $op, $arg3 = NULL, $arg4 = NULL) {
  if ($txn == 'donate' && $op == 'review') {
    return 'donate';
  }

  if (is_array($txn)) {
    // Check to see if we have a donation in the cart
    foreach ($txn->items as $no => $key) {
      if ($key->ptype == 'donate') {
        $display = TRUE;
      }
    }
    if (!$display) {
      return;
    }
  }

  switch ($op) {
    case 'review':
      $form['donate_gift_aid'] = array(
        '#type' => 'item',
        '#description' => variable_get('donate_gift_aid_text', ''),
      );
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => $txn->misc['gift_aid'] ? t('Remove') : t('Add'),
      );
      return $form;
      break;
    case 'review_submit':
      if ($_POST['op'] == 'Add') {
        $misc = new StdClass;
        $misc->type = 'donate';
        $misc->description = 'Gift Aid';
        $txn->misc['gift_aid'] = $misc;
      }
      elseif ($_POST['op'] == 'Remove') {
        foreach ($txn->misc as $no => $key) {
          if ($key->type == 'donate') {
            unset($txn->misc[$no]);
          }
        }
      }
      elseif ($_POST['op'] == 'Place your order') {
        // Do nothing...  Was a breakpoint for testing
      }
      break;
  }
}

function theme_donate_review_form($form) {
  $output.= '<div class="container-inline">';
  $output.= drupal_render($form);
  $output.= '</div>';
  return theme('box', t('Include Gift Aid?'), $output);
}

I've flushed my cache. Are using an old version as the latest has "E-Commerce Configuration" with the following sections, store, Invoice, Location, Mail, Payment, Screen order and User account.

I can't see any change to the donation page or anything added to the configuration screens.

pobster’s picture

Heh ;o) Was trying to avoid posting all that code! But yes, that's correct! Well... At the very least the menu item should now be appearing? Strange... I'm wondering whether you've set everything up correctly? ...Just to check something... You have created your donation using the donation product type right? And not as a simple non-shippable product? Could you just check that the donate module is activated on your modules page for me?

Ta :o)

Pobster

Redsmartie’s picture

Yes, Donations are enabled and it was created as create content>product>donation

pobster’s picture

Nuts! Well it was a long shot! Okay... Go to /node/add/page and use the php input filter and type;

menu_rebuild();

Then PREVIEW (not submit) and now check your ecsettings page - if donate is still not there contact me using my Drupal contact form and I'll get to the bottom of what's going on.

Thanks,

Pobster

Redsmartie’s picture

I ran update.php and now have a dontate item in EC-Configuration. I've added my text but there is still no change to the donation page, no text and no check box.

Redsmartie’s picture

I've sent you a mail ;)

pobster’s picture

Hi! Yes and I replied but your mail server greylisted me and rejected it!!!

"Recipient address rejected: Greylisted for 2 minutes (in reply to RCPT TO command)"

Odd!

Anyways, Gift Aid seems to be working fine? Don't forget what I said before that the Gift Add part doesn't appear until you checkout (?q=cart/review).

BTW, it's really easy to show how much the 28% comes to in the cart - I can do this if you want?

edit: now blacklisted!!! type=MX: Host not found, try again

Pobster

Redsmartie’s picture

I have it working now on my sandbox site. Since it appears at checkout it also seems to work regardless of it being a non-shippable product or donation.

I'll do more testing. I'm thinking of leaving the original gift aid solution and wording this on the summary as "have you remembered gift aid?" that way I have belt and braces to make sure that I collect the 28%.

Not sure why you are having mail trouble??!!

pobster’s picture

I had it set up originally to say something like 'Gift Aid adds an extra £xx.xx to your donation at no cost to you' where the £xx.xx is created dynamically from the amount you donate (obviously!) Then across from that it confirms the sub-total is £0.00 - thought that was a nice touch, but the text was a little on the long side so I removed it. Just thought I'd let you know that something like this *is* possible.

And yeah the mail trouble? That's really weird! I've *never* had that before! It seems you're still blacklisting me! Do you host your mail yourself? I'd be interested in your logs!

Thanks,

Pobster

Redsmartie’s picture

My mail is hosted with servage.net

I've just sent to my domain from my .Mac account and it was fine. In fact I just got one of your mails re. your test transaction

rwbgb’s picture

Hi,

I followed the above instructions carefully and added the code to the bottom of the donate.module as described (found in modules/ecommerce/contrib/donate). I was adding to a 5.x site and the last post of code above from redsmartie just worked for me.

I took the liberty of making a few additions to this to make it slightly clearer to the end user. Using the code below you can configure the message before they click "Add Gift Aid" and after, it also make the text bold to prompt them to click!

function donate_menu($may_cache) {
  $items  = array();
  $access = user_access('administer store');

  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/ecsettings/donate',
      'title' => 'donate',
      'callback' => 'drupal_get_form',
      'callback arguments' => array('donate_settings'),
      'access' => $access,
      'type' => MENU_NORMAL_ITEM,
    );
  }
  return $items;
}

function donate_settings() {
  drupal_set_title('Donate module settings');
  $form['donate_gift_aid_add_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Gift Aid Add text'),
    '#default_value' => variable_get('donate_gift_aid_add_text', ''),
    '#description' => t('Enter descriptive text to be displayed beneath gift aid checkbox.'),
  );
  $form['donate_gift_aid_remove_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Gift Aid Remove text'),
    '#default_value' => variable_get('donate_gift_aid_remove_text', ''),
    '#description' => t('Enter descriptive text to be displayed beneath gift aid checkbox.'),
  );
  return system_settings_form($form);
}

function donate_checkoutapi(&$txn, $op, $arg3 = NULL, $arg4 = NULL) {
  if ($txn == 'donate' && $op == 'review') {
    return 'donate';
  }

  if (is_array($txn)) {
    // Check to see if we have a donation in the cart
    foreach ($txn->items as $no => $key) {
      if ($key->ptype == 'donate') {
        $display = TRUE;
      }
    }
    if (!$display) {
      return;
    }
  }

  switch ($op) {
    case 'review':
      $form['donate_gift_aid'] = array(
        '#type' => 'item',
        '#description' => ($txn->misc['gift_aid'] ? variable_get('donate_gift_aid_remove_text', '') : '<span style="font-size:1.1em; font-weight:bold;">' . variable_get('donate_gift_aid_add_text', '') . '</span>') . '<br/><br/>',
      );
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => ($txn->misc['gift_aid'] ? t('Remove') : t('Add')) . ' Gift Aid',
      );
      return $form;
      break;
    case 'review_submit':
      if ($_POST['op'] == 'Add Gift Aid') {
        $misc = new StdClass;
        $misc->type = 'donate';
        $misc->description = 'Gift Aid';
        $txn->misc['gift_aid'] = $misc;
      }
      elseif ($_POST['op'] == 'Remove Gift Aid') {
        foreach ($txn->misc as $no => $key) {
          if ($key->type == 'donate') {
            unset($txn->misc[$no]);
          }
        }
      }
      elseif ($_POST['op'] == 'Place your order') {
        // Do nothing...  Was a breakpoint for testing
      }
      break;
  }
}

function theme_donate_review_form($form) {
  $output.= '<div class="container-inline">';
  $output.= drupal_render($form);
  $output.= '</div>';
  return theme('box', t('Include Gift Aid?'), $output);
}

Thanks pobster for writing this.

http://www.networkmenus.co.uk - Better Social Bookmarking

rwbgb’s picture

Sorry after changing the module I did have to create a page, add a title, add the body:

<?php
menu_rebuild();
?>

Set the input format to be PHP then preview the page. After this the Donate link can be seen from the Ecommerce Admin. Some text for your messages too:

Add:
Please click below if you are a UK tax payer as you can donate an additional 28% for free.

Remove:
Click below if you are not a UK tax payer as you are unable to donate an additional 28% for free.

http://www.networkmenus.co.uk - Better Social Bookmarking for your Business

pobster’s picture

Hey there!

No worries, glad to have helped! :o)

Pobster