From 0164cfe71d0eea4e497e7db2d10e8aab25cf957d Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 1 Jan 2024 16:06:45 +1300 Subject: [PATCH] Reload submitted line items on re-submit of Main form --- CRM/Contribute/Form/Contribution/Main.php | 7 +++++++ CRM/Financial/BAO/Order.php | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index b3120cf913..5f7851a2cf 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -1170,10 +1170,17 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu /** * Process the form submission. + * + * @throws \CRM_Core_Exception */ public function postProcess() { // we first reset the confirm page so it accepts new values $this->controller->resetPage('Confirm'); + // Update order to the submitted values (in case the back button has been used + // and the submitted values have changed. + $this->set('lineItem', NULL); + $this->order->setPriceSelectionFromUnfilteredInput($this->getSubmittedValues()); + $this->order->recalculateLineItems(); // get the submitted form values. $params = $this->controller->exportValues($this->_name); diff --git a/CRM/Financial/BAO/Order.php b/CRM/Financial/BAO/Order.php index ec85b13fec..0230d46735 100644 --- a/CRM/Financial/BAO/Order.php +++ b/CRM/Financial/BAO/Order.php @@ -822,6 +822,17 @@ class CRM_Financial_BAO_Order { return $this->lineItems; } + /** + * Recalculate the line items. + * + * @return void + * + * @throws \CRM_Core_Exception + */ + public function recalculateLineItems(): void { + $this->lineItems = $this->calculateLineItems(); + } + /** * Get line items in a 'traditional' indexing format. * -- 2.25.1