CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Multiple currency options
Pages: [1]

Author Topic: Multiple currency options  (Read 1360 times)

jeevajoy

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: joomal 1.6
  • MySQL version: 5
  • PHP version: 5
Multiple currency options
December 01, 2011, 08:29:03 am
Hi,

I've  started working in bringing Multiple Currency options. I'm new to civicrm. Does anybody know how to get currency from Available Currencies in Localization??


Cheers

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Multiple currency options
December 01, 2011, 11:41:54 am

can you explain a bit more on what you are trying to do?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jeevajoy

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: joomal 1.6
  • MySQL version: 5
  • PHP version: 5
Re: Multiple currency options
December 02, 2011, 01:32:20 am
I'm trying to get the Mutiple currency options for the user in the contribution page.
I tried to get the list of currencies in the available currencies in localization.



I managed to do that. Now i need to change the default currency according to the selection.

jeevajoy

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: joomal 1.6
  • MySQL version: 5
  • PHP version: 5
Re: Multiple currency options
December 05, 2011, 08:58:23 am
<?php
          function civicrm_multicurrency_civicrm_buildForm( $formName,
                                    &$form ) {
                                                                         
         if( $formName=='CRM_Contribute_Form_Contribution_Main'){
         require_once 'CRM/Core/OptionGroup.php';
         $enabledCurrencies = CRM_Core_OptionGroup::values( 'currencies_enabled' );
         $form->addElement('select', 'activeCurrencies', ts('Select Currency'), $enabledCurrencies);
   
   }
}

function civicrm_multicurrency_civicrm_buildAmount( $pageType,
                                      &$form,
                                      &$amount ) {                                                                                                                                if($pageType == 'contribution' && $form->_submitValues['activeCurrencies'] != '' ) {
         $value= $form->_submitValues;
         $c = $value['activeCurrencies'];
               
         static $processed = false;
             
        $config    =& CRM_Core_Config::singleton( );
        $config->defaultCurrency = $c;         
        return $config->defaultCurrency;   
       
    }
}

here is  my hook functions for multicurrency option. But in the Confirmation page it remains USD $. When i change in any other currency it only changes in Main Page.

Anyone pls help.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Multiple currency options
December 05, 2011, 09:51:25 am

1. might want to look at this module:

http://svn.civicrm.org/tools/trunk/drupal/modules/multicurrency/multicurrency.module

2. Basically u need to set / extract the value from the "form submitted values" using exportValues. In the confirm page, the submitted values dont have the active currency. I would do somethign like:

// in main page buildForm
$form->set( 'activeCurrencies', DEFAULT VALUE );
$config->default_currency = DEFAULT VALUE;

// in main page postProcess
$form->set( 'activeCurrencies', VALUE SELECTED AS ACTIVE CURRENCY );

// in confirm and thank you pages buildForm
$config->default_currency = $form->get( 'activeCurrencies' );

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jeevajoy

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: joomal 1.6
  • MySQL version: 5
  • PHP version: 5
Re: Multiple currency options
December 06, 2011, 01:53:00 am
hi lobo,

Thank you very much. Now i understood...

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Multiple currency options

This forum was archived on 2017-11-26.