seikan / Cart

A simple PHP shopping cart class to use in ecommerce web applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with cart update after removal of first item in product group

SolidGeek opened this issue · comments

First of all, thanks for the class, it works great. However, I found a small bug while using product variants. If you add two or more variants of the same product to the cart, and removes the one with index 0, the indexing goes bad. This is because, the array doesn't get re-indexed after item removal, and each cart operation starts at index 0. I found that re-indexing the variant arrays after the removal of a variant fixes this.

public function remove($id, $attributes = []){
...
unset($this->items[$id][$index]);
$this->items[$id] = array_values($this->items[$id]);
...
}