From 93647195726ba2e42fc5fabca05b5e3d3ef3da05 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 10 Nov 2023 16:41:00 +1300 Subject: [PATCH] Fix notice on is_quick_config is_quick_config is only assigned when a payment is being made on an existing contribution - this was a bit hard to figure out so I switched to using a variable that explicitly says what it means (rather than guess at ccid) and ensured that is_quick_config was only accessed within these blocks Also, I pulled the assignment on the Dummy processor name from out of the unrelated function --- CRM/Contribute/Form/Contribution/Main.php | 16 +++++++--------- .../CRM/Contribute/Form/Contribution/Main.tpl | 10 +++++----- .../Form/Contribution/MainMembershipBlock.tpl | 4 +++- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 1840f71540..419c0f4b07 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -70,12 +70,17 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu /** * Set variables up before form is built. + * + * @throws \CRM_Core_Exception + * @throws \CRM_Contribute_Exception_InactiveContributionPageException */ public function preProcess() { parent::preProcess(); $this->_paymentProcessors = $this->get('paymentProcessors'); $this->preProcessPaymentOptions(); + // If the in-use payment processor is the Dummy processor we assign the name so that a test warning is displayed. + $this->assign('dummyTitle', $this->getPaymentProcessorValue('payment_processor_type_id.class') === 'CRM_Dummy' ? $this->getPaymentProcessorValue('payment_processor_type_id.front_end_title') : ''); $this->assignFormVariablesByContributionID(); @@ -1438,14 +1443,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu * Set form variables if contribution ID is found */ public function assignFormVariablesByContributionID(): void { - $dummyTitle = 0; - foreach ($this->_paymentProcessors as $pp) { - if ($pp['class_name'] === 'Payment_Dummy') { - $dummyTitle = $pp['name']; - break; - } - } - $this->assign('dummyTitle', $dummyTitle); + $this->assign('isPaymentOnExistingContribution', (bool) $this->getExistingContributionID()); $this->assign('pendingAmount', $this->getContributionBalance()); if (empty($this->getExistingContributionID())) { return; @@ -1457,8 +1455,8 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $lineItems = $this->getExistingContributionLineItems(); $this->assign('lineItem', [$this->getPriceSetID() => $lineItems]); - $this->assign('is_quick_config', $this->isQuickConfig()); $this->assign('priceSetID', $this->getPriceSetID()); + $this->assign('is_quick_config', $this->isQuickConfig()); } /** diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 33ff5ce7f3..2d22dbfe8b 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -8,7 +8,7 @@ +--------------------------------------------------------------------+ *} {* Callback snippet: On-behalf profile *} -{if $snippet and !empty($isOnBehalfCallback) and !$ccid} +{if $snippet and !empty($isOnBehalfCallback) and !$isPaymentOnExistingContribution}
{include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"}
@@ -54,7 +54,7 @@
{crmRegion name='contribution-main-not-you-block'} - {if $contact_id && !$ccid} + {if $contact_id && !$isPaymentOnExistingContribution} @@ -70,11 +70,11 @@
{ts}You have a current Lifetime Membership which does not need to be renewed.{/ts}
{/if} - {if $isShowMembershipBlock && !$ccid} + {if $isShowMembershipBlock && !$isPaymentOnExistingContribution}
{include file="CRM/Contribute/Form/Contribution/MainMembershipBlock.tpl"}
- {elseif !empty($ccid)} + {elseif $isPaymentOnExistingContribution} {if $lineItem && $priceSetID && !$is_quick_config}
{ts}Contribution Information{/ts}{if $display_name} – {$display_name}{/if} @@ -93,7 +93,7 @@
{/if} - {if !$ccid} + {if !$isPaymentOnExistingContribution} {crmRegion name='contribution-main-pledge-block'} {if $pledgeBlock} {if array_key_exists('pledge_amount', $form)} diff --git a/templates/CRM/Contribute/Form/Contribution/MainMembershipBlock.tpl b/templates/CRM/Contribute/Form/Contribution/MainMembershipBlock.tpl index 23b2f2b4de..d676d6a3a9 100644 --- a/templates/CRM/Contribute/Form/Contribution/MainMembershipBlock.tpl +++ b/templates/CRM/Contribute/Form/Contribution/MainMembershipBlock.tpl @@ -73,7 +73,9 @@ {/literal}
-{if $membershipBlock AND $is_quick_config} +{if $isPaymentOnExistingContribution && $membershipBlock && $is_quick_config} + {* This code is hit only when ccid is in the url to pay on an existing contribution and it is quick config *} + {* Removing the contents of this if does not result in any apparent change & it may be removable *} {strip} {foreach from=$membershipTypes item=row} -- 2.25.1