Crinsane / LaravelShoppingcart

A simple shopping cart implementation for Laravel
MIT License
3.67k stars 1.73k forks source link

When I call Cart::restore(1) data get Deleted??? #627

Open SaddamDeveloper opened 4 years ago

SaddamDeveloper commented 4 years ago

When I call Cart::restore(1) data get Deleted after Saving the Data Cart::store(1)??? What's the problem

bumbummen99 commented 4 years ago

If i get you right then its not a bug but a feature 😄 https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L399 https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L400 The general workflow of this package is that the cart is either in DB or loaded, not booth. There is a PR on my fork to change this but it is not yet merged.

SaddamDeveloper commented 4 years ago

either in DB or Session, not both

I guess??

limsocheat commented 3 years ago

This method work for me. when using with API. need to restore and store it back.

\Cart::restore(\Auth::user()->uuid);
$item   = \Cart::content();
\Cart::store(\Auth::user()->uuid);