moltin / laravel-cart

Laravel Facade and Service Provider for Moltin\Cart
276 stars 87 forks source link

Trying to make every cart item separate #26

Closed timparnell closed 10 years ago

timparnell commented 10 years ago

I'm attempting to modify the cart to list every item individually - even duplicate products. I'm picking up someone else's project and have been asked to modify it. Totally new to Laravel so I'm out my depth

i found in Cart::insert the check if an item is already in the basket, but I can't understand how to give it a new $itemidentifier if it already exists.

if ($this->has($itemIdentifier)) {
    $item['quantity'] = $this->item($itemIdentifier)->quantity + $item['quantity']; 

I'm guessing i need to modify createItemIdentifier somehow but every attempt so far has just resulted in adding to the cart not adding the item (I think I'm just changing the $itemIdentifier for the existing cart item not creating a new one). Just looking for a pointer of where to look, please.

timparnell commented 10 years ago

I have now discovered how to proceed with this. The original implementation didn't use the options array correctly. It is now working fine.