Answers.Body: <p>Maybe a bit late but we've implemented gift aid for a client's donations site and whilst in Craft2 and using the Charge plugin it might help a bit.</p>
  
  <p>We added a field to the Charge order which is a lightswitch of GiftAid on or off. As August suggested this could be done in the line item as an options[giftaid] value of Craft Commerce</p>
  
  <p>We then created a couple of twig templates restricted to admin users only. The first one is an index file that lists the calendar months as links to another twig template that lists the details of that months orders as a CSV file for GiftAid reporting. </p>
  
  <p>The code for the css twig template looks like this:</p>
  
  <pre><code>{% set month = craft.request.getParam('d') %}
  {% set year = craft.request.getParam('y') %}
  {% set firstDay = date(year ~ '-' ~ month ~ '-01') %}
  {% set lastDay = firstDay|date_modify('first day of next month') %}
  {% header "Content-Type: application/csv" %}
  {% header "Content-Disposition: attachment; filename=" ~ month ~ "-" ~ year ~ "-GiftAidReport.csv" %}
  {% set postDateParam = ['and', '&gt;= ' ~ firstDay|date('c'), '&lt; ' ~ lastDay|date('c')] %}
  {% set charges = craft.charge.charges({  
      giftAid: 1,
      dateCreated: postDateParam,
      refunded: false
  })%}
  CharityNumber, CharityName, ProjectName, FundraisingCampaign, DonorTitle,DonorFirstName,DonorLastName,DonorAddress,DonorPostcode, Description, DonatonDate, DonationAmount, DonationCurrency, GiftAidValue
  {% for charge in charges %}
  {% set thisName = charge.customer.name|split(' ') %}
  &lt;this is your list of CSV fields&gt;
  {% endfor %}
  </code></pre>
  
  <p>I'm sure there is a much nicer way of doing this all in a plugin within the backend but this was a nice quick and easy way to do it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-28T12:59:00.947Z
Answers.LastActivityDate: 2019-03-28T12:59:00.947Z
Answers.UserDisplayName: stuh
Body: <p>The new donations purchasable looks super handy for charity websites, thank you for this :)</p>
  
  <p>In the UK we have a thing called <a href="https://www.gov.uk/claim-gift-aid" rel="nofollow noreferrer">Gift Aid</a> that allows charities to claim an extra 25% on donations/purchases if the customer opts into the scheme.</p>
  
  <p>Is there any way you could modify the new Donation purchasable so that two (or more) kinds of donation can be logged in Craft?</p>
  
  <p>Eg something like <code>craft.commerce.donation.type(normal)</code> and <code>craft.commerce.donation.type(giftaid)</code> - and then ideally a way to export a CSV of each donation type via the control panel?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T21:21:11.457Z
Comments.Text: PS. Realise is might be a feature request on a new feature, sorry for being that guy
Comments.UserDisplayName: James Greig
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T23:20:00.770Z
Comments.Text: I imagine Gift Aid generates a bit of search traffic, so I wanted to offer an interim solution (in lieu of a first-party "Product Type"-esque architecture)… in our experience, this is an opt-in program, so it might be possible to achieve the desired functionality by adding a lightswitch field to the order or donation line-item?
Comments.UserDisplayName: August Miller
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T23:23:10.690Z
Comments.Text: Part of the motivation for providing this is that—because it factors in the donor's preference—it might be easier to allow them to flip it on and off, rather than clear a cart or switch `Purchasable`s, on-the-fly?
Comments.UserDisplayName: August Miller
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-06T03:58:44.837Z
Comments.Text: Thanks @August - you can add fields to line items!?
Comments.UserDisplayName: James Greig
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-06T20:06:15.000Z
Comments.Text: Not _fields_ proper—but you can drop whatever you want into the `options` attribute for a `LineItem`, by sending it along with your payload: `<input type="checkbox" name="purchasables[][options][myKey]" value="1">`. If necessary, you can validate that data from a plugin/module, in an event listener! See: https://github.com/craftcms/commerce/blob/master/src/controllers/CartController.php#L201
Comments.UserDisplayName: August Miller
Tags: <plugin-craftcommerce2><modules><donations>
Title: Create different types of Donation purchasable? (for Gift Aid etc)
ThreadText: # Create different types of Donation purchasable? (for Gift Aid etc)
  
  (Asked by: username_0 on 2019-03-05)
  
  The new donations purchasable looks super handy for charity websites, thank you for this :)
  
  In the UK we have a thing called [Gift Aid](https://www.gov.uk/claim-gift-aid) that allows charities to claim an extra 25% on donations/purchases if the customer opts into the scheme.
  
  Is there any way you could modify the new Donation purchasable so that two (or more) kinds of donation can be logged in Craft?
  
  Eg something like `craft.commerce.donation.type(normal)` and `craft.commerce.donation.type(giftaid)` - and then ideally a way to export a CSV of each donation type via the control panel?
  
  **Tags:** plugin-craftcommerce2, modules, donations
  
  > **Comments:**
  > **username_0**: PS. Realise is might be a feature request on a new feature, sorry for being that guy  
  > **username_1**: I imagine Gift Aid generates a bit of search traffic, so I wanted to offer an interim solution (in lieu of a first-party "Product Type"-esque architecture)… in our experience, this is an opt-in program, so it might be possible to achieve the desired functionality by adding a lightswitch field to the order or donation line-item?  
  > **username_1**: Part of the motivation for providing this is that—because it factors in the donor's preference—it might be easier to allow them to flip it on and off, rather than clear a cart or switch `Purchasable`s, on-the-fly?  
  > **username_0**: Thanks @username_1 - you can add fields to line items!?  
  > **username_1**: Not _fields_ proper—but you can drop whatever you want into the `options` attribute for a `LineItem`, by sending it along with your payload: `<input type="checkbox" name="purchasables[][options][myKey]" value="1">`. If necessary, you can validate that data from a plugin/module, in an event listener! See: https://github.com/craftcms/commerce/blob/master/src/controllers/CartController.php#L201  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-03-28. Score: 1
  
  Maybe a bit late but we've implemented gift aid for a client's donations site and whilst in Craft2 and using the Charge plugin it might help a bit.
  
  We added a field to the Charge order which is a lightswitch of GiftAid on or off. As username_1 suggested this could be done in the line item as an options[giftaid] value of Craft Commerce
  
  We then created a couple of twig templates restricted to admin users only. The first one is an index file that lists the calendar months as links to another twig template that lists the details of that months orders as a CSV file for GiftAid reporting.
  
  The code for the css twig template looks like this:
  
  ```
  {% set month = craft.request.getParam('d') %}
  {% set year = craft.request.getParam('y') %}
  {% set firstDay = date(year ~ '-' ~ month ~ '-01') %}
  {% set lastDay = firstDay|date_modify('first day of next month') %}
  {% header "Content-Type: application/csv" %}
  {% header "Content-Disposition: attachment; filename=" ~ month ~ "-" ~ year ~ "-GiftAidReport.csv" %}
  {% set postDateParam = ['and', '>= ' ~ firstDay|date('c'), '< ' ~ lastDay|date('c')] %}
  {% set charges = craft.charge.charges({  
      giftAid: 1,
      dateCreated: postDateParam,
      refunded: false
  })%}
  CharityNumber, CharityName, ProjectName, FundraisingCampaign, DonorTitle,DonorFirstName,DonorLastName,DonorAddress,DonorPostcode, Description, DonatonDate, DonationAmount, DonationCurrency, GiftAidValue
  {% for charge in charges %}
  {% set thisName = charge.customer.name|split(' ') %}
  <this is your list of CSV fields>
  {% endfor %}
  
  ```
  
  I'm sure there is a much nicer way of doing this all in a plugin within the backend but this was a nice quick and easy way to do it.
  
  
  ---
  
  