darryldecode / laravelshoppingcart

Shopping Cart Implementation for Laravel Framework
1.32k stars 413 forks source link

¿How can I prevent the items in the cart from changing position? #367

Open alquialrium opened 11 months ago

alquialrium commented 11 months ago

How can I prevent the items in the cart from changing position when I change the quantity of a product?

I think they are ordered according to the update and put them below, but I don't know where I can modify it.

gantira commented 9 months ago

i use orderBy id to prevent changing position

imnhasan commented 5 months ago

i use orderBy id to prevent changing position

How to make this one orderBy

$cartItem = \Cart::session($this->userId)->getContent();
imnhasan commented 5 months ago

I have a solution to do that, you can also try this way.

$cartItem = \Cart::session($userId)->getContent()->sortKeysDesc();