Adding Items to the cart will increase the cart jobs count while emptying the cart or removing items from the cart will not decrease the total number displayed.
I tracked this issue and found the following.
The constructor is assigning the SESSION to the cart variable by reference.
Emptying the cart will remove this reference by assigning a new empty array to the cart variable which will make it impossible at this case to update the values stored in the session.
<?php
protected function __construct() {
if (!isset($_SESSION[$this->session_key])) {
$_SESSION[$this->session_key] = array();
}
$this->cart = &$_SESSION[$this->session_key];
}
?>
<?php
public function emptyCart() {
$this->cart = array();
}
?>
I recommend using manipulating the SESSION values directly without using a reference.
Comments
Comment #2
mqannehComment #3
mqannehComment #4
mqannehComment #5
berdirI'm not sure I understand. Would be great to expand our test coverage to show the bug :)
Comment #6
mqannehjust try to add items to the cart then remove done of them.
When you add items the cart counter will be increased while removing items won't change the count.
apply my patchand test again
;)
Comment #7
leksat commentedI can't reproduce this. For me
$this->cart = array()does not break the reference to$_SESSION[$this->session_key]. See https://3v4l.org/rQ8jEMaybe this is somehow related to #2629800: PDOException: When trying to empty an empty cart?
Comment #8
mqanneh@leksat to reproduce this ...
try removing some items from your cart and check the cart menu item, it will not change.
apply the patch and try again.
Comment #10
mqanneh