Fix for CRM-17905
authorsunil <esunil.pawar@gmail.com>
Sat, 30 Jan 2016 11:40:02 +0000 (17:10 +0530)
committersunil <esunil.pawar@gmail.com>
Sat, 30 Jan 2016 11:40:02 +0000 (17:10 +0530)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Price/BAO/PriceField.php

index 69856982eaaeb3a05c498a879ac1bda3dfaa81d7..4ad1d8e479a3673d85b47921c5f2c00e56e04337 100644 (file)
@@ -919,10 +919,11 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
 
     // store the fact that this is a membership and membership type is selected
     $processMembership = FALSE;
+    $priceFieldIds = $this->get('memberPriceFieldIDS');
     if ((!empty($membershipParams['selectMembership']) &&
         $membershipParams['selectMembership'] != 'no_thanks'
       ) ||
-      $this->_useForMember
+      ( $this->_useForMember && !empty($priceFieldIds) )
     ) {
       $processMembership = TRUE;
 
index 4819f9677cb715a25d28d915495f1503f2f78e6f..c074b6f58fc9eab105af7ab36c5261d3d78b675d 100644 (file)
@@ -894,6 +894,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
       if ($self->_useForMember == 1 && !empty($check) && $membershipIsActive) {
         $priceFieldIDS = array();
         $priceFieldMemTypes = array();
+        $priceFieldIsRequired = array();
 
         foreach ($self->_priceSet['fields'] as $priceId => $value) {
           if (!empty($fields['price_' . $priceId]) || ($self->_quickConfig && $value['name'] == 'membership_amount' && empty($self->_membershipBlock['is_required']))) {
@@ -918,6 +919,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
                   )
                 ) {
                   $priceFieldMemTypes[] = $val['membership_type_id'];
+                  $priceFieldIsRequired[$priceId] = $value['is_required'];
                 }
               }
             }
@@ -948,7 +950,8 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
           }
         }
 
-        if (empty($priceFieldMemTypes)) {
+        $priceFieldIsRequired = array_filter($priceFieldIsRequired);
+        if (empty($priceFieldMemTypes) && !empty($priceFieldIsRequired)) {
           $errors['_qf_default'] = ts('Please select at least one membership option.');
         }
       }
index cc0aee8609b3eb3275c69f794fe6b68abd593e81..51dfd3637dd86dc4c40a322301710a6357018641 100644 (file)
@@ -445,6 +445,13 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField {
           }
           else {
             $none = ts('- none -');
+            if (!empty($qf->_membershipBlock) && empty($qf->_quickConfig)) {
+              foreach($fieldOptions as $fieldOption) {
+                if (CRM_Utils_Array::value('membership_type_id', $fieldOption) ) {
+                  $none = ts('No thank you');
+                }
+              }
+            }
           }
 
           $choice[] = $qf->createElement('radio', NULL, '', $none, '0',