From 85fd1b178d960893eb98ffa55a78a93b97f97e7e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 8 May 2023 15:45:13 +1200 Subject: [PATCH] Fix regression whereby membership does not submit --- CRM/Contribute/Form/Contribution/Main.php | 25 +++---------------- .../Form/Contribution/MembershipBlock.tpl | 3 ++- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 28d3b62023..7062877578 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -511,6 +511,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $this->_currentMemberships = []; $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()); $allowAutoRenewMembership = $autoRenewOption = FALSE; @@ -634,28 +635,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $autoRenewOption = CRM_Price_BAO_PriceSet::checkAutoRenewForPriceSet($this->_priceSetId); $this->assign('autoRenewOption', $autoRenewOption); - if (!$membershipPriceset) { - if (!$this->_membershipBlock['is_required']) { - $this->assign('showRadioNoThanks', TRUE); - $radio['no_thanks'] = NULL; - $this->addRadio('selectMembership', NULL, $radio, [], NULL, FALSE, $radioOptAttrs); - } - elseif ($this->_membershipBlock['is_required'] && count($radio) == 1) { - $temp = array_keys($radio); - $this->add('hidden', 'selectMembership', $temp[0], ['id' => 'selectMembership']); - $this->assign('singleMembership', TRUE); - $this->assign('showRadio', FALSE); - } - else { - foreach ($radioOptAttrs as $opt => $attrs) { - $attrs['class'] = ' required'; - } - $this->addRadio('selectMembership', NULL, $radio, [], NULL, FALSE, $radioOptAttrs); - } - - $this->addRule('selectMembership', ts('Please select one of the memberships.'), 'required'); - } - if ((!$this->_values['is_pay_later'] || is_array($this->_paymentProcessors)) && ($allowAutoRenewMembership || $autoRenewOption)) { if ($autoRenewOption == 2) { $this->addElement('hidden', 'auto_renew', ts('Please renew my membership automatically.')); @@ -783,6 +762,8 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $self->_useForMember ) ) { + + // appears to be unreachable - selectMembership never set... $isTest = $self->_action & CRM_Core_Action::PREVIEW; $lifeMember = CRM_Member_BAO_Membership::getAllContactMembership($self->_membershipContactID, $isTest, TRUE); diff --git a/templates/CRM/Contribute/Form/Contribution/MembershipBlock.tpl b/templates/CRM/Contribute/Form/Contribution/MembershipBlock.tpl index 796834c64b..4ad6d4ad82 100644 --- a/templates/CRM/Contribute/Form/Contribution/MembershipBlock.tpl +++ b/templates/CRM/Contribute/Form/Contribution/MembershipBlock.tpl @@ -158,6 +158,7 @@ {foreach from=$membershipTypes item=row} {if $showRadio } + {* unreachable - show radio is never true *} {assign var="pid" value=$row.id} {$form.selectMembership.$pid.html} {else} @@ -203,7 +204,7 @@ {/if} - {if $showRadio} + {if $showRadio}{* unreachable *} {if $showRadioNoThanks } {* Provide no-thanks option when Membership signup is not required - per membership block configuration. *} {$form.selectMembership.no_thanks.html} -- 2.25.1