Upcoming Events
San Francisco CiviCRM Meetup - February 8th, 2012
February 8th, 2012
Come meet others from the Bay Area who are interested in, using or developing (more...)
UK usergroup - London meetup
February 8th, 2012
Come and meet others from the UK that are using CiviCRM or are interested in (more...)
Chicago CiviCRM Meetup
February 17th, 2012
Please join other CiviCRM users, administrators, and developers in the Chicago (more...)
London user and administrator training
February 23rd, 2012
A comprehensive two day hands on training course covering the configuration, (more...)
CiviCRM London sprint Feb 2012
February 27th, 2012
Following the CiviCRM training here in London, we will have a CiviCRM code (more...)
Philadelphia - CiviCRM Meetup for Q1 2012
March 13th, 2012
UK South West - CiviCRM Meetup
March 20th, 2012
Come meet others from the Area who are interested in, using or developing for (more...)
[Bristol, UK] user and administrator training
March 21st, 2012
A comprehensive hands on training course covering the configuration, (more...)
San Francisco user and administrator training
March 29th, 2012
A comprehensive two day hands on training course covering the configuration, (more...)
CiviCRM Usability, Test and Code Sprint - San Francisco (March 2012)
March 29th, 2012
This usability, code and test sprint is targeted at CiviCRM users and (more...)
CiviCon 2012 San Francisco Bay Area - April 2nd 2012
April 2nd, 2012
CiviCon is THE annual event bringing together the people who use, develop, (more...)
CiviCRM Documentation, Test and Code Sprint - after CiviCon San Francisco (April 2012)
April 4th, 2012
This sprint is targeted at CiviCRM users and developers who want to work on (more...)
New in 2.2: State-Country widget, customizing event registration amounts for members
- Not Just a Contact Database
-
These optional components give you more power to connect and engage your supporters.

civiCASE
Case management for clients and constituents.

civiCONTRIBUTE
Online fundraising and donor management.

civiEVENT
Online event registration and participant tracking.

civiMEMBER
Online signup and membership management.

civiMAIL
Personalized email blasts and newsletters.

civiREPORT
Report generation and template management.
Our global meeting resulted in some new features being added to 2.2. Our team worked on a new jQuery based country/state selector and incorporating hook(s) to the "amount" functionality of online contribution and event registration pages. I'll give a brief description of the feature set and functionality of these projects
New jQuery based State Country widget
Our previous widget was a dojo based combo box widget. Both the country and the state were ajax based combo boxes. The state combo box was dependent on the value chosen in the country combo box. This implementation was quite complex and not easily replicated (hence u did not see the widget in many places). For 2.2 we took a slightly different approach: The country field is a simple html select box (the values are restricted by the countries configured in the admin area). The state selector is now dynamic and refreshed with new values whenever the country is changed. We took inspiration and borrowed a fair part of the code from: Simple chained combobox plugin for jQuery.
This model is much easier to replicate and we've introduced it in a more places including profiles, contribution pages and event registration pages. It was kinda nice to see the number of lines of js code being deleted with this new scheme. We felt quite bad that we did not think of doing it this way to begin with, but you learn as you grow :)
Extending the "amounts" field in transaction pages
One request that we hear quite often is: How do we make prices for an event dynamic, so our members get a 10% discount (or $10 off). Trying to add this logic via the UI did not seem easy since different folks had different requirements. We also wanted to make similar changes to the contribution pages, so an org could tailor the amounts displayed to a logged in user based on their past giving history (i.e. increase the donation amounts displayed if the donor has given significant amounts in the recent past).
We've been incorporating hooks into many places in CiviCRM, and this seemed another good place to use hooks. Deepak and I spent an afternoon reworking the code to facilitate this along with a sample hook implementation. The good news was the code was in pretty good shape that we wrapped the project up quite quickly. We standardized on the amount structure across contributions and events. An example hook implementation which gives a discount to all Student members is as follows:
function civitest_civicrm_buildAmount( $pageType,
&$form,
&$amount ) {
// lets add an arbitrary amount here, just to show folks
// the power of a hook :)
$amount[1000] = array( 'value' => 400,
'label' => 'Hook',
'amount_id' => 1000 );
// now lets get a bit more ambitious
// *GOAL*: lets plan to give 20% discount to students
$membershipType = 'Student';
$discountPercent = 20;
// get the membership-type-id for the membership-type
$membershipTypeId = CRM_Core_DAO::getFieldValue( 'CRM_Member_DAO_MembershipType',
$membershipType,
'id',
'name' );
// get the logged in user id
$session =& CRM_Core_Session::singleton();
$userID = $session->get( 'userID' );
if ( $userID ) {
// check if logged in user has 'Student' membership
require_once 'CRM/Member/BAO/Membership.php';
$membership = CRM_Member_BAO_Membership::getContactMembership( $userID, $membershipTypeId, null );
// If logged in contact is a member as on today, modify the amount
// to reflect the discount.
if ( CRM_Utils_Array::value( 'is_current_member', $membership ) ) {
foreach ( $amount as $amountId => $amountInfo ) {
$amount[$amountId]['value'] = $amount[$amountId]['value'] -
ceil($amount[$amountId]['value'] * $discountPercent / 100);
$amount[$amountId]['label'] = $amount[$amountId]['label'] .
"\t - with {$discountPercent}% discount (for $membershipType)";
}
}
}
}







Comments
can $membershipType be an array?
we'd like to extend a discount to multiple membership types