Commit cd843ddc authored by mattwire's avatar mattwire

Add function to get configured currency for contributionpage/event registration page

parent 700cf121
......@@ -9,7 +9,7 @@
trait CRM_Core_Payment_MJWTrait {
/**********************
* MJW_Core_Payment_MJWTrait: 20190901
* MJW_Core_Payment_MJWTrait: 20190905
*********************/
/**
......@@ -166,6 +166,29 @@ trait CRM_Core_Payment_MJWTrait {
}
}
/**
* Get the currency configured for the form when it is loaded
*
* @param \CRM_Core_Form $form
*
* @return string
*/
public function getDefaultCurrencyForForm($form) {
// For contribution pages it is in $form->_values
$currency = CRM_Utils_Array::value('currency', $form->_values);
if (!$currency) {
// For event pages it is in $form->_values['event']
if (isset($form->_values['event'])) {
$currency = CRM_Utils_Array::value('currency', $form->_values['event']);
}
}
if (!$currency) {
// If we can't find it we'll use the default from the configuration
$currency = CRM_Core_Config::singleton()->defaultCurrency;
}
return $currency;
}
/**
*
* @param array $params ['name' => payment instrument name]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment