From 26b9275f35c8b09c6a3c0023ccb46c469b3f9da9 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 14 Sep 2021 16:47:26 +0100 Subject: [PATCH] Don't allow changing amount on UpdateSubscription form --- CRM/Contribute/Form/UpdateSubscription.php | 10 +++++++++- templates/CRM/Contribute/Form/UpdateSubscription.tpl | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/Form/UpdateSubscription.php b/CRM/Contribute/Form/UpdateSubscription.php index e38baacc44..a5772c74ce 100644 --- a/CRM/Contribute/Form/UpdateSubscription.php +++ b/CRM/Contribute/Form/UpdateSubscription.php @@ -151,10 +151,18 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib if (count($lineItems) > 1) { $amtAttr += ['readonly' => TRUE]; } - $this->addMoney('amount', ts('Recurring Contribution Amount'), TRUE, $amtAttr, + $amountField = $this->addMoney('amount', ts('Recurring Contribution Amount'), TRUE, $amtAttr, TRUE, 'currency', $this->_subscriptionDetails->currency, TRUE ); + // The amount on the recurring contribution should not be updated directly. If we update the amount using a template contribution the recurring contribution + // will be updated automatically. + $paymentProcessorObj = Civi\Payment\System::singleton()->getById(CRM_Contribute_BAO_ContributionRecur::getPaymentProcessorID($this->contributionRecurID)); + $templateContribution = CRM_Contribute_BAO_ContributionRecur::getTemplateContribution($this->contributionRecurID); + if (!empty($templateContribution['id']) && $paymentProcessorObj->supportsEditRecurringContribution()) { + $amountField->freeze(); + } + $this->add('text', 'installments', ts('Number of Installments'), ['size' => 20], FALSE); if ($this->_donorEmail) { diff --git a/templates/CRM/Contribute/Form/UpdateSubscription.tpl b/templates/CRM/Contribute/Form/UpdateSubscription.tpl index 06f77a01b2..c49249f3b0 100644 --- a/templates/CRM/Contribute/Form/UpdateSubscription.tpl +++ b/templates/CRM/Contribute/Form/UpdateSubscription.tpl @@ -19,6 +19,12 @@ {/if}
{include file="CRM/common/formButtons.tpl" location="top"}
+ {if $form.amount.frozen} +
+ {icon icon="fa-info-circle"}{/icon} + {ts}To change the amount you need to edit the template contribution. Click on "View Template" and then "Edit" from the list of recurring contributions{/ts} +
+ {/if} -- 2.25.1
{$form.amount.label}