diff --git a/CHANGELOG.md b/CHANGELOG.md index db8176cd95..581e518cc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Fixed a PHP error that could occur when processing a payment. ([#3092](https://github.com/craftcms/commerce/issues/3092)) +- Fixed a bug that could occur when forgetting a cart. ([#3091](https://github.com/craftcms/commerce/pull/3091)) ## 4.2.5.1 - 2023-02-02 diff --git a/src/services/Carts.php b/src/services/Carts.php index 7ae65dd2f0..f055185c2c 100644 --- a/src/services/Carts.php +++ b/src/services/Carts.php @@ -207,7 +207,11 @@ public function forgetCart(): void $this->_cart = null; $this->_cartNumber = null; if (!Craft::$app->getRequest()->getIsConsoleRequest()) { - Craft::$app->getResponse()->getCookies()->remove($this->cartCookie['name'], true); + $cookie = Craft::createObject(array_merge($this->cartCookie, [ + 'class' => Cookie::class, + ])); + + Craft::$app->getResponse()->getCookies()->remove($cookie, true); } }