laravelshoppingcart icon indicating copy to clipboard operation
laravelshoppingcart copied to clipboard

Do I need to use the Cart :: session ($ userId) -> method view each time?

Open Shaykhnazar opened this issue 4 years ago • 2 comments

Do I need to use the Cart :: session ($ userId) -> method view each time? public function __construct() { $userId = auth()->user()->id; Cart::session($userId); } or does he use it in subsequent methods by writing once? like public function delete($id) { // removing cart item cart Cart::remove(456);

return back()->with('success_message', __('Item deleted!')); }

Shaykhnazar avatar Aug 30 '20 06:08 Shaykhnazar

How do I save cart item rowID? where rowID is stored and how I can access it?

Shaykhnazar avatar Aug 30 '20 07:08 Shaykhnazar

@Shaykhnazar please refer to docs. they are quite self explanatory and simple. Or better have a look at demo with git.

If you are binding $userId to your cart then everywhere it does requires. so while removing use this method.. Cart::session($userId)->remove(456);

ilyaskazi avatar Sep 28 '20 07:09 ilyaskazi