Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Extension module for Drupal Commerce, providing:

  • Contribution product type,
  • Contribution display content type,
  • Contribution line item,
  • rules,
  • views.

Inspired by Randy Fay's idea of using Custom Line Items to provide a donation feature to Drupal Commerce.

Developed in line with new Drupal Commerce approach of making as few hard-coded assumptions as possible about how a site's eCommerce systems should function - therefore using only entities, rules and views, with nothing hard-coded, and all features imported through Features module, thus making them fully configurable and changeable.

Built as much more flexible alternative to Commerce Contributions module, trying not to force any behaviors on the end users and avoid creating new products for each contribution transaction.

Contribution product type

  • Uses commerce_price field as Target amount - a maximum amount that can be contributed to each project.
  • Defines new field field_already_contributed used for storing total already contributed amount for each project.

Contribution display content type

Content type used specifically for displaying Contribution products on the site.

Contribution line item

  • Defines new Price-type field field_contribution_amount used on Add to Cart forms for entering contribution amount.

Rules

  • Merge line item quantities
    Updates line items having quantities higher than 1 back to 1, at the same time multiplying their previous unit price by previous quantity.
  • Merge duplicate contribution products + Sum duplicate contribution product amounts
    Merge multiple line items for the same product into one, adding up their unit prices.
  • Disallow too big contributions + Calculate total contribution for a product + Compare total contribution with target amount
    Makes sure that sum of all previous contributions for a specific product and new Contribution amount entered when adding a Contribution product to shopping cart do not exceed Target amount defined for a product.
  • Use contribution amount in line item
    Updates line item Unit price with Contribution amount entered when adding a Contribution product to shopping cart.
  • Update total contribution amounts from completed order + Update total contribution amount for a product
    Update contribution product's Already contributed field value after order has been marked as completed.

Views

  • admin Contributions, available in admin area, listing all contributions,
  • User contribution, available in user profile, listing only user contributions.

Requirements

Issues

  • There is some funny behavior when importing Contribution line item type feature, when sometimes two new line item types are being created, one of those without the machine name. If such thing happens to you just get rid of the additional line item type.

Project Information