LaravelShoppingcart icon indicating copy to clipboard operation
LaravelShoppingcart copied to clipboard

Can you just create a getRowID function?

Open kev1ncal opened this issue 3 years ago • 2 comments

Is this some kind of magical way of getting an item in the cart? Why do you have to make the rowId as the most important thing to search for items inside the cart? e.g get() function requires rowId instead of the given ID?

kev1ncal avatar Aug 05 '20 05:08 kev1ncal

Take a look at https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L330 RowID is based on the ID and Options so you can add the same Product but with different options resulting in different Positions/Items on the Cart. For example if you add a Product instance it has multiple variances like color or size etc which should be treated as seperate positions in the calculation but not necessarily as seperate models in your data structure, therefore the identifier for the CartItem has to be a combination of the ID and the options (hash).

bumbummen99 avatar Aug 05 '20 20:08 bumbummen99