Refactor so functions that add payment to register form are next to each other
authorMatthew Wire <mjw@mjwconsult.co.uk>
Thu, 24 Nov 2022 16:05:59 +0000 (16:05 +0000)
committerMatthew Wire <mjw@mjwconsult.co.uk>
Mon, 8 May 2023 19:05:25 +0000 (20:05 +0100)
CRM/Event/Form/Registration/Register.php

index 8b0b0263498aaca1267f4ae0248e8fd5ae16f7e3..b84e15ba1ac120a2187f265999d04f9c20646ab3 100644 (file)
@@ -355,17 +355,6 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     // CRM-18399: used by template to pass pre profile id as a url arg
     $this->assign('custom_pre_id', $this->_values['custom_pre_id']);
 
-    // Required for currency formatting in the JS layer
-
-    // Required for currency formatting in the JS layer
-    // this is a temporary fix intended to resolve a regression quickly
-    // And assigning moneyFormat for js layer formatting
-    // will only work until that is done.
-    // https://github.com/civicrm/civicrm-core/pull/19151
-    $this->assign('moneyFormat', CRM_Utils_Money::format(1234.56));
-
-    CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
-
     $contactID = $this->getContactID();
     $this->assign('contact_id', $contactID);
     if ($contactID) {
@@ -432,7 +421,15 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     $this->assign('isAdditionalParticipants', $isAdditionalParticipants);
 
     if ($this->_values['event']['is_monetary']) {
+      // Required for currency formatting in the JS layer
+      // this is a temporary fix intended to resolve a regression quickly
+      // And assigning moneyFormat for js layer formatting
+      // will only work until that is done.
+      // https://github.com/civicrm/civicrm-core/pull/19151
+      $this->assign('moneyFormat', CRM_Utils_Money::format(1234.56));
       self::buildAmount($this);
+      CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
+      $this->addPaymentProcessorFieldsToForm();
     }
 
     if ($contactID === 0 && !$this->_values['event']['is_multiple_registrations']) {
@@ -440,12 +437,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
       $this->addCIDZeroOptions();
     }
 
-    if ($this->_values['event']['is_monetary']) {
-      $this->addPaymentProcessorFieldsToForm();
-    }
-
     $this->addElement('hidden', 'bypass_payment', NULL, ['id' => 'bypass_payment']);
-
     $this->assign('bypassPayment', $bypassPayment);
 
     if (!$contactID) {