Skip to content

Commit

Permalink
Set currency template variable from contribution pages
Browse files Browse the repository at this point in the history
When we load the PaymentForm the currency is set there and assigned to the template.

However, if the form doesn't load by default (ie because there is no payment processor selected by
default) the currency variable is not assigned to the template.

When the payment form is loaded by
      var dataUrl = '{crmURL p='civicrm/payment/form' h=0 q=formName=
  • Loading branch information
eileenmcnaughton committed Nov 26, 2018
1 parent 116d9f2 commit d02c641
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CRM/Contribute/Form/ContributionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,13 @@ public function preProcess() {
$this->_defaults = array();

$this->_amount = $this->get('amount');
// Assigning this to the template means it will be passed through to the payment form.
// This can, for example, by used by payment processors using client side encryption
$this->assign('currency', $this->getCurrency());

//CRM-6907
// these lines exist to support a non-default currenty on the form but are probably
// obsolete & meddling wth the defaultCurrency is not the right approach....
$config = CRM_Core_Config::singleton();
$config->defaultCurrency = CRM_Utils_Array::value('currency',
$this->_values,
Expand Down
3 changes: 1 addition & 2 deletions CRM/Core/Payment/ProcessorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public static function preProcess(&$form, $type = NULL, $mode = NULL) {

$form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons());

$currency = $form->getCurrency();
$form->assign('currency', $currency);
$form->assign('currency', $form->getCurrency());

// also set cancel subscription url
if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) {
Expand Down

0 comments on commit d02c641

Please sign in to comment.