From: eileen Date: Mon, 1 Jan 2024 03:06:45 +0000 (+1300) Subject: Reload submitted line items on re-submit of Main form X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0164cfe71d0eea4e497e7db2d10e8aab25cf957d;p=civicrm-core.git Reload submitted line items on re-submit of Main form --- 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. *