diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index eb2979e4dd69..da53dd02054e 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -512,32 +512,29 @@ private function buildMembershipBlock() { $membershipTypeIds = $membershipTypes = $radio = $radioOptAttrs = []; // This is always true if this line is reachable - remove along with the upcoming if. - $membershipPriceset = (!empty($this->_priceSetId) && $this->isMembershipPriceSet()); + $membershipPriceset = TRUE; $allowAutoRenewMembership = $autoRenewOption = FALSE; $autoRenewMembershipTypeOptions = []; $separateMembershipPayment = $this->_membershipBlock['is_separate_payment'] ?? NULL; - if ($membershipPriceset) { - foreach ($this->_priceSet['fields'] as $pField) { - if (empty($pField['options'])) { + foreach ($this->_priceSet['fields'] as $pField) { + if (empty($pField['options'])) { + continue; + } + foreach ($pField['options'] as $opId => $opValues) { + if (empty($opValues['membership_type_id'])) { continue; } - foreach ($pField['options'] as $opId => $opValues) { - if (empty($opValues['membership_type_id'])) { - continue; - } - $membershipTypeIds[$opValues['membership_type_id']] = $opValues['membership_type_id']; - } + $membershipTypeIds[$opValues['membership_type_id']] = $opValues['membership_type_id']; } } - elseif (!empty($this->_membershipBlock['membership_types'])) { - $membershipTypeIds = explode(',', $this->_membershipBlock['membership_types']); - } if (!empty($membershipTypeIds)) { //set status message if wrong membershipType is included in membershipBlock + // @todo - this appears to be unreachable - it seems likely it has been broken for + // a while so remove may be an OK alternative to fix if ($this->getRenewalMembershipID() && !$membershipPriceset) { $membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->getRenewalMembershipID(),