From a52f79838f42faa546b4987bafcaf7c93869f8d2 Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Mon, 3 Feb 2025 13:15:06 +0800 Subject: [PATCH 1/2] Move recalculation inside of cart controller --- src/controllers/CartController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/controllers/CartController.php b/src/controllers/CartController.php index e2e93f0e85..344062ad48 100644 --- a/src/controllers/CartController.php +++ b/src/controllers/CartController.php @@ -526,6 +526,9 @@ private function _returnCart(): ?Response $updateCartSearchIndexes = Plugin::getInstance()->getSettings()->updateCartSearchIndexes; + $this->_cart->recalculate(); + $this->_cart->recalculationMode = Order::RECALCULATION_MODE_NONE; + // Do not clear errors, as errors could be added to the cart before _returnCart is called. if (!$this->_cart->validate($attributes, false) || !Craft::$app->getElements()->saveElement($this->_cart, false, false, $updateCartSearchIndexes)) { $error = Craft::t('commerce', 'Unable to update cart.'); @@ -559,6 +562,8 @@ private function _returnCart(): ?Response $this->_mutex->release($this->_mutexLockName); } + $this->_cart->recalculationMode = Order::RECALCULATION_MODE_ALL; + return $this->asModelSuccess( $this->_cart, $message, From 4e02749036e9e764653c061f285d9ed21aeeac79 Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Tue, 4 Feb 2025 19:45:25 +0800 Subject: [PATCH 2/2] Add release notes --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 150a80e4c3..a24575e6a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft Commerce +## Unreleased + +- Fixed a bug where the `commerce/cart/update-cart` action could return unnecessary validation errors. ([3873](https://github.com/craftcms/commerce/issues/3873)) + ## 4.8.0.1 - 2025-02-03 - Fixed a bug where the deprecated `TaxRate::$isVat` property was still being set. ([#3874](https://github.com/craftcms/commerce/issues/3874))