[REF] move definition of important values & retrieval outside payment-object 'if...
authoreileen <emcnaughton@wikimedia.org>
Wed, 9 Oct 2019 08:12:02 +0000 (10:12 +0200)
committereileen <emcnaughton@wikimedia.org>
Wed, 9 Oct 2019 08:12:02 +0000 (10:12 +0200)
The concepts of billingMode is deprecated - goal is not to have separate handling for each one

CRM/Event/Form/Registration.php
CRM/Event/Form/Registration/Confirm.php

index 2ac411173084408c1538eda1749c9c219b116bc4..d0c51c77222ea962d15df64dc7174b19359dee26 100644 (file)
@@ -725,6 +725,8 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
       // CRM-10032
       $this->processFirstParticipant($participant->id);
     }
+    $this->_params['participantID'] = $participant->id;
+    $this->set('primaryParticipant', $this->_params);
 
     CRM_Core_BAO_CustomValueTable::postProcess($this->_params,
       'civicrm_participant',
@@ -752,13 +754,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
       $paymentPartcipant = CRM_Event_BAO_ParticipantPayment::create($paymentParams);
     }
 
-    //set only primary participant's params for transfer checkout.
-    // The concept of contributeMode is deprecated.
-    if (($this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') && !empty($this->_params['is_primary'])) {
-      $this->_params['participantID'] = $participant->id;
-      $this->set('primaryParticipant', $this->_params);
-    }
-
     $this->assign('action', $this->_action);
 
     // create CMS user
index 05b5aa02aedeadfe16401a36c249921abd97dce3..6076724b3d0719f36313128ea4985af7e278104a 100644 (file)
@@ -737,6 +737,15 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       $isTest = TRUE;
     }
 
+    $primaryParticipant = $this->get('primaryParticipant');
+
+    if (empty($primaryParticipant['participantID'])) {
+      CRM_Core_Error::deprecatedFunctionWarning('This line is not logically reachable.');
+      $primaryParticipant['participantID'] = $registerByID;
+    }
+    //otherwise send mail Confirmation/Receipt
+    $primaryContactId = $this->get('primaryContactId');
+
     // for Transfer checkout.
     // The concept of contributeMode is deprecated.
     if (($this->_contributeMode == 'checkout' ||
@@ -746,12 +755,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       $this->_totalAmount > 0
     ) {
 
-      $primaryParticipant = $this->get('primaryParticipant');
-
-      if (empty($primaryParticipant['participantID'])) {
-        $primaryParticipant['participantID'] = $registerByID;
-      }
-
       //build an array of custom profile and assigning it to template
       $customProfile = CRM_Event_BAO_Event::buildCustomProfile($registerByID, $this->_values, NULL, $isTest);
       if (count($customProfile)) {
@@ -826,8 +829,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       }
     }
     else {
-      //otherwise send mail Confirmation/Receipt
-      $primaryContactId = $this->get('primaryContactId');
 
       //build an array of cId/pId of participants
       $additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($registerByID,