Skip to content

Commit

Permalink
Update getHasSessionCartNumber() to make sure it checks carts cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed Feb 27, 2024
1 parent f4f38c0 commit 04bbd83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft Commerce

## Unreleased

- Fixed a bug where `craft\commerce\services\Carts::getHasSessionCartNumber()` wasn’t checking the cart cookie. ([#3353](https://github.com/craftcms/commerce/issues/3353))

## 4.5.0 - 2024-02-26

- Removed the Lite edition.
Expand Down
13 changes: 12 additions & 1 deletion src/services/Carts.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,18 @@ public function getCartName(): string
*/
public function getHasSessionCartNumber(): bool
{
return $this->_cartNumber !== null && $this->_cartNumber !== false;
if ($this->_cartNumber === false) {
return false;
}

if ($this->_cartNumber === null) {
$request = Craft::$app->getRequest();
$requestCookies = $request->getCookies();

return $requestCookies->getValue($this->cartCookie['name'], false) !== false;
}

return true;
}

/**
Expand Down

0 comments on commit 04bbd83

Please sign in to comment.