Fix regression whereby membership does not submit
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 8 May 2023 03:45:13 +0000 (15:45 +1200)
committerTim Otten <totten@civicrm.org>
Mon, 8 May 2023 20:35:43 +0000 (13:35 -0700)
CRM/Contribute/Form/Contribution/Main.php
templates/CRM/Contribute/Form/Contribution/MembershipBlock.tpl

index 9819e8276c08a261535ceaaf09498406a88a83a1..fa3b1c71e5ab77b6c2f0634b98e9cb02698890fc 100644 (file)
@@ -512,6 +512,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;
@@ -635,28 +636,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.'));
@@ -784,6 +763,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);
 
index 796834c64bd9ccf9259d646b9018020cb044ad7e..4ad6d4ad8280c18476ed2da26cc0edaca5657a73 100644 (file)
       {foreach from=$membershipTypes item=row}
         <tr {if $context EQ "makeContribution"}class="odd-row" {/if}valign="top">
           {if $showRadio }
+            {* unreachable - show radio is never true *}
             {assign var="pid" value=$row.id}
             <td style="width: 1em;">{$form.selectMembership.$pid.html}</td>
           {else}
           </td>
         </tr>
       {/if}
-      {if $showRadio}
+      {if $showRadio}{* unreachable *}
         {if $showRadioNoThanks } {* Provide no-thanks option when Membership signup is not required - per membership block configuration. *}
           <tr class="odd-row">
             <td>{$form.selectMembership.no_thanks.html}</td>