CRM-18071 fix
authordeb.monish <monish.deb@webaccessglobal.com>
Thu, 17 Mar 2016 17:31:45 +0000 (23:01 +0530)
committerdeb.monish <monish.deb@webaccessglobal.com>
Thu, 17 Mar 2016 19:20:50 +0000 (00:50 +0530)
minor fix

style fix

style fix

CRM/Contribute/Form/Contribution/Confirm.php

index 8a6db269bb304c5fc02c98f261d7cf373119ac47..96cee5ea1674d01f6439d8c1d1d029fc6e77c9a5 100644 (file)
@@ -1592,6 +1592,18 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       // This feels like a bizarre hack as the variable name doesn't seem to be directly connected to it's use in the template.
       $emailValues['useForMember'] = 0;
       $emailValues['amount'] = 0;
+
+      //CRM-18071, where on selecting $0 free membership payment section got hidden and
+      // also it reset any payment processor selection result into pending free membership
+      // so its a kind of hack to complete free membership at this point since there is no $form->_paymentProcessor info
+      if (empty($form->_params['is_pay_later']) && !empty($membershipContribution) && !is_a($membershipContribution, 'CRM_Core_Error')) {
+        $paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values));
+        if (empty($form->_paymentProcessor) && !empty($paymentProcessorIDs)) {
+          $this->_paymentProcessor['id'] = $paymentProcessorIDs[0];
+        }
+        $result = array('payment_status_id' => 1, 'contribution' => $membershipContribution);
+        $this->completeTransaction($result, $result['contribution']->id);
+      }
     }
 
     CRM_Contribute_BAO_ContributionPage::sendMail($contactID,
@@ -1910,7 +1922,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       // (note it might make sense to make this a row in the processor table in the db).
       $this->_params['payment_processor_id'] = 0;
     }
-    if (isset($this->_params['payment_processor_id']) && $this->_params['payment_processor_id'] == 0) {
+    if (isset($this->_params['payment_processor_id']) && $this->_params['payment_processor_id'] === 0) {
       $this->_params['is_pay_later'] = $isPayLater = TRUE;
     }
     // add a description field at the very beginning