Answer the question
In order to leave comments, you need to log in
How to save shopping map in laravel cookies?
An unregistered user adds an item to the cart. Sessions are stored in Cookies - rearranged in the config.
The question is how to correctly read and write data,
I threw it in but it did not work.
public function addProduct($productId){
if (array_has(Session::get('cart.items'),$productId))
return Session::get('cart.items');
Session::push('cart.items',$productId);
return Session::get('cart.items');
}
Answer the question
In order to leave comments, you need to log in
I did this: The recording was in js, and the reading was in php.
Stored ID and amount in json
If the goal is to do it quickly and efficiently, with your experience, you should not write this functionality from scratch.
There are a bunch of ready-made basket packages. My Favorites:
https://github.com/darryldecode/laravelshoppingcart
https://github.com/Crinsane/LaravelShoppingcart
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question