From 4b315f6d48e4138559826af0eccc62ea5cf6c165 Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Mon, 3 Jul 2023 14:26:36 +0800 Subject: [PATCH] Fixed #3206 --- CHANGELOG.md | 1 + src/controllers/CartController.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63860eccf3..940741a549 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Fixed a bug where address changes weren’t being synced to carts using them as a source. ([#3178](https://github.com/craftcms/commerce/issues/3178)) - Added `craft\commerce\services\Orders::afterSaveAddressHandler()`. - Added `craft\commerce\elements\Order::$orderCompletedEmail`. ([#3138](https://github.com/craftcms/commerce/issues/3138)) +- Added the `commerce/cart/forget-cart` action. ([#3206](https://github.com/craftcms/commerce/issues/3206)) ## 4.2.11 - 2023-06-05 diff --git a/src/controllers/CartController.php b/src/controllers/CartController.php index 3754a074a7..aad1586e95 100644 --- a/src/controllers/CartController.php +++ b/src/controllers/CartController.php @@ -277,6 +277,20 @@ public function actionUpdateCart(): ?Response return $this->_returnCart(); } + /** + * @return Response|null + * @throws BadRequestHttpException + * @throws InvalidConfigException + * @since 4.3 + */ + public function actionForgetCart(): ?Response + { + $this->requirePostRequest(); + Plugin::getInstance()->getCarts()->forgetCart(); + $this->setSuccessFlash(Craft::t('commerce', 'Cart forgotten.')); + return $this->redirectToPostedUrl(); + } + /** * @throws BadRequestHttpException * @throws Exception