Skip to content

Commit

Permalink
First pass at not setting the cookie unless cart interaction occurrs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Nov 13, 2023
1 parent 997cc85 commit 7e68452
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/services/Carts.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ public function init()
// If we have a cart cookie, assign it to the cart number.
// Also check pre Commerce 4.0 for a cart number in the session just in case.
if ($requestCookies->has($this->cartCookie['name'])) {
$this->setSessionCartNumber($requestCookies->getValue($this->cartCookie['name']));
$this->_cartNumber = $requestCookies->getValue($this->cartCookie['name']);
if($this->_cart && $this->_cart->number != $this->_cartNumber) {
$this->_cart = null;
}
} elseif (($session->getHasSessionId() || $session->getIsActive()) && $session->has('commerce_cart')) {
$this->setSessionCartNumber($session->get('commerce_cart'));
$session->remove('commerce_cart');
Expand Down

0 comments on commit 7e68452

Please sign in to comment.