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