Get currency from the event
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 28 Nov 2023 22:03:02 +0000 (11:03 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 28 Nov 2023 22:03:02 +0000 (11:03 +1300)
CRM/Event/Form/Participant.php

index 2d846e993418aa9dc793fbfe3726f6a0f3dee1de..d5c7502ef8b65d4c8ac289653554aad82a513113 100644 (file)
@@ -1244,12 +1244,6 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     $form->_pId = CRM_Utils_Request::retrieve('participantId', 'Positive', $form);
     $form->_discountId = CRM_Utils_Request::retrieve('discountId', 'Positive', $form);
 
-    //CRM-6907 set event specific currency.
-    if ($form->_eventId &&
-      ($currency = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'currency'))
-    ) {
-      CRM_Core_Config::singleton()->defaultCurrency = $currency;
-    }
     if ($form->_eventId) {
       $form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary');
       if ($form->_isPaidEvent) {
@@ -1486,6 +1480,15 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     $this->assign('event', ['confirm_email_text' => $receiptText]);
   }
 
+  /**
+   * Get the currency for the event.
+   *
+   * @return string
+   */
+  public function getCurrency() {
+    return $this->getEventValue('currency') ?: \Civi::settings()->get('defaultCurrency');
+  }
+
   /**
    * Process the contribution.
    *