From 78b191a8fe7dd6f140dd15828609be14659d58b6 Mon Sep 17 00:00:00 2001 From: sunil Date: Sat, 30 Jan 2016 17:10:02 +0530 Subject: [PATCH] Fix for CRM-17905 --- CRM/Contribute/Form/Contribution/Confirm.php | 3 ++- CRM/Contribute/Form/Contribution/Main.php | 5 ++++- CRM/Price/BAO/PriceField.php | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 69856982ea..4ad1d8e479 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -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; diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 4819f9677c..c074b6f58f 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -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.'); } } diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index cc0aee8609..51dfd3637d 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -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', -- 2.25.1