courtly
courtly
courtly
courtly

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...)

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...)

CiviCRM Components

Tools for engaging your supporters...

CiviContribute


CiviEvent


CiviMail


CiviMember


CiviReport


Multi-currency support for CiviCRM v2.2.3

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.

  • 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.

May 5, 2009 - 13:28 — lobo

The CiviCRM team is planning to hold a UK and Europe developer camp and user meetup in the last week of June 23-27 (if you are interested in attending, please do take this survey.)

A couple of months ago, we decided to run CiviCRM on the civicrm.org servers. Eating your own dog food does spur quite a bit of changes and tweaks to make the product a lot more usable :). For the event in the UK, we needed to accept payment in either euros or pounds. However we do not have multi-currency support within CiviEvent :(

Once again, Drupal hooks and custom templates to the rescue. I implemented two hooks, the buildForm hook to set the currency in the config object

function civicrm_civicrm_buildForm( $formName,
                                    &$form ) {
    if ( ( ( strpos( $formName, 'CRM_Event_Form_Registration_' ) !== false ) && ( $form->getVar( '_eventId' ) == 1 ) ) ||
         ( ( strpos( $formName, 'CRM_Contribute_Form_Contribution_' ) !== false ) && ( $form->getVar( '_id' ) == 1 ) ) ) {
        civicrm_set_currency( $form );
    }
}

function civicrm_set_currency( &$form ) {
    static $processed = false;

    if ( $processed ) {
        return;
    }

    $processed = true;
    $currency  = CRM_Utils_Request::retrieve( 'currency', 'String', $form, false, 'GBP' );
    $config    =& CRM_Core_Config::singleton( );
    if ( strtoupper( $currency ) == 'EUR' ) {
        $config->defaultCurrency = 'EUR';
    } else {
        $config->defaultCurrency = 'GBP';
    }

    return $config->defaultCurrency;
}

and the buildAmount hook to modify the amount based on the currency chosen


function civicrm_civicrm_buildAmount( $pageType,
                                      &$form,
                                      &$amount ) {
    // only modify the event pages for the UK event                                                                                                                                       
    if ( $form->getVar( '_id' ) == 1 ||
         $form->getVar( '_eventId' ) != 1 ) {
        $currency = civicrm_set_currency( $form );

        // as of may 5th: 1 USD = 0.75 EUR, 1 USD = 0.667 GBP                                                                                                                             
        $ratio = ( $currency == 'EUR' ) ? 0.75 : ( 2.0 / 3.0 );

        foreach ( $amount as $amountID =>& $amountInfo ) {
            $amountInfo['value'] = ceil( $amountInfo['value'] * $ratio );
        }
    }
}

I also needed a way to allow folks to switch to the currency of their choice. I created a custom template for that event and added the following section to the Register.tpl file just above the payment options

{if $config->defaultCurrency eq 'EUR'}
{ts}If you want to pay in pounds, click {/ts}<a href="{crmURL p='civicrm/event/register' q="reset=1&id=`$event.id`¤cy=GBP"}"title="{ts}Pay for Camp in pounds.{/ts}">{ts}here{/ts}</a>
{else}
{ts}If you want to pay in euros, click {/ts}<a href="{crmURL p='civicrm/event/register' q="reset=1&id=`$event.id`¤cy=EUR"}"title="{ts}Pay for Camp in euros.{/ts}">{ts}here\{/ts}</a>
{/if}

Finally i had to go in and make some changes to some of the core files to allow multiple currencies and group together currencies of the same type. I made the required changes to the contribution search and summary screens. I think I've got most of it. Some of the issues filed for this feature are here:

Allow hooks to control defaultCurrency
Add multi currency support to CiviCRM
Participant record does not have a fee_currency field

Big tip of the hat to Tom (mrfelton on #civicrm) for his initial thoughts and ideas on how to go about addressing this issue

( categories: )

Comments

hi did you finish this one or

hi did you finish this one or else working

How can I use this information?

How can I use this information to build an event that works with Euros while the default currency of my site is USD?

mrfelton on #civicrm = Tom,

mrfelton on #civicrm = Tom, not Ken! but thanks all the same!!