seikan / Cart

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Item not always removing

rasselll opened this issue · comments

Hi using your example, I have found that an item sometimes 1 item does not get removed. tried to add 3 items of the same id with different colors, and removing although get this error:

2018-05-13_22-48-53

However sometimes there is no error and just doesnt allow me to delete the rest of the items. See if you're able to reproduce this error, by just adding different colors of the same product. then deleting one by one, you'll see that for some reason one of them wont delete

hi to solve this issue just need to change the foreach in remove to

 foreach ($this->items[$id] as $index => $item) {
    ...
}

Also the way you calculate the hash doesn't seem very robust and strongly relies on the order of your input array. Could you please change this or make it more robust

Thanks. There is a bug when removing cart item. It has been fixed. The hash is just an unique ID to identify each item in the cart. It's not necessary to be complex.