Laravelshoppingcart: Restoring cart delete the cart row

Created on 24 Aug 2017  Â·  7Comments  Â·  Source: Crinsane/LaravelShoppingcart

I try to store cart on database it's stored successfully but when restore this cart my return is null
i noticed that after use restore() function the car has removed from DB

My Example

 Cart::instance('shopping')->add('192ao12', 'Product 1', 1, 9.99);
 Cart::instance('shopping')->store('foo');
 dd(Cart::instance('shopping')->restore('foo'));

Or
dd(Cart::restore('foo'));

Any Help ,Thanks

Most helpful comment

hi crinsane
thank you again for a nice package.
you commented [https://github.com/Crinsane/LaravelShoppingcart/issues/143] that you add store() and restore() , thank you , but I think you can make it perfect by adding update() function ,
for example , user login on pc and add to cart 3 product , and later he login on his mobile , we want show the user his cart item , and if user add or remove item we update shopingcart table and so on .
could you please give me an example how can i handle it ?

All 7 comments

There is no anyone help me here , please .

in case if the your item has been stored in the database
it may the caches still got that null value
try to clear caches
php artisan cache:clear
php artisan config:clear
and restore the server

@33sKamal thanks for reply , i tried to clear cache and config but still the same issue

Hi i have tried all above solution but it is not working and facing same issue.Can anyone help me out for this?

The problem here is that you’re using this functionality in another way than originally it was intented for.
The idea is for you to store the cart for a later time. So maybe a customer can “save his cart for the next time he/she visits”.

What you’re trying to do is use this functionality t save the cart to the db all the time. But it is not designed for that purpose

hi crinsane
thank you again for a nice package.
you commented [https://github.com/Crinsane/LaravelShoppingcart/issues/143] that you add store() and restore() , thank you , but I think you can make it perfect by adding update() function ,
for example , user login on pc and add to cart 3 product , and later he login on his mobile , we want show the user his cart item , and if user add or remove item we update shopingcart table and so on .
could you please give me an example how can i handle it ?

Seriously as @saeed7m say, we need to keep cart item between all devises

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abdullahkaamil picture abdullahkaamil  Â·  3Comments

shakhawatfci picture shakhawatfci  Â·  10Comments

hasanali05 picture hasanali05  Â·  6Comments

gauravojha picture gauravojha  Â·  8Comments

sobhanattar picture sobhanattar  Â·  4Comments