dev/core#4282 Fix isShowMembershipBlock
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 19 May 2023 02:47:39 +0000 (14:47 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 19 May 2023 02:49:33 +0000 (14:49 +1200)
As determined by Konadave & myself this
isShowMembershipBlock was always true when memberships were in
play in 5.60 - despite various code comments. I have renamed
& assigned it regardless of QuickConfig. Since it is
a condition of including the tpl & within it it already checks
the context I made the context check the top level check & removed the
isShowMembershipBlock check

CRM/Contribute/Form/ContributionBase.php
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Contribute/Form/Contribution/MembershipBlock.tpl

index 1d41e1ae54cf9a67d98dc5ad075351558a109da7..fb6f61e3e719c77396cc32392cd14c70ce831216 100644 (file)
@@ -446,7 +446,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
       $this->set('values', $this->_values);
       $this->set('fields', $this->_fields);
     }
-    $this->assign('isShowMembershipQuickConfigBlock', $this->isShowMembershipQuickConfigBlock());
+    $this->assign('isShowMembershipBlock', $this->isShowMembershipBlock());
     $this->set('membershipBlock', $this->getMembershipBlock());
 
     // Handle PCP
@@ -1327,11 +1327,15 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
   /**
    * Should the membership block be displayed.
    *
-   * This should be shown when the price set is quick config and is a membership price set.
+   * This should be shown when a membership is available to purchase.
+   *
+   * It could be a quick config price set or a standard price set that extends
+   * CiviMember.
+   *
    * @return bool
    */
-  protected function isShowMembershipQuickConfigBlock(): bool {
-    return CRM_Core_Component::isEnabled('CiviMember') && $this->getMembershipBlock() && $this->isQuickConfig();
+  protected function isShowMembershipBlock(): bool {
+    return CRM_Core_Component::isEnabled('CiviMember') && $this->getMembershipBlock();
   }
 
   /**
index 3a0c541a7e33f3b430d96b9177a65bfd02d0a3d8..e1d71b5d91814bedcc7f759b08f6bcc50c97243a 100644 (file)
@@ -76,7 +76,7 @@
       <div class="help">{ts}You have a current Lifetime Membership which does not need to be renewed.{/ts}</div>
     {/if}
 
-    {if $isShowMembershipQuickConfigBlock && !$ccid}
+    {if $isShowMembershipBlock && !$ccid}
       <div class="crm-public-form-item crm-section">
         {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="makeContribution"}
       </div>
index fd70bbe2495630e2227a7fa721a8054c833b0623..848e2d73d7b152bb73dc11771faa49451cfe2edf 100644 (file)
@@ -7,9 +7,9 @@
  | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
 *}
-{if $isShowMembershipQuickConfigBlock}
+{if $context EQ "makeContribution"}
   <div id="membership" class="crm-group membership-group">
-    {if $context EQ "makeContribution"}
+
       <div id="priceset">
         <fieldset>
           {if $renewal_mode}
@@ -61,7 +61,7 @@
       <div class="display-block">
         {include file="CRM/Price/Page/LineItem.tpl" context="Membership"}
       </div>
-    {/if}
+
   </div>
 {literal}
   <script type="text/javascript">