yiiext / shopping-cart-component

Allows to put models into shopping cart and do various operations with it.
80 stars 35 forks source link

Problem with the cart, when i get items into the cart with logged in user.... #8

Open igorsavinkin opened 10 years ago

igorsavinkin commented 10 years ago

Problem with the cart. When i get items into the cart with logged in user the cart is ok. When i log out the cart gets empty. If i log in with the same user, whose cart has not been empty, the cart DOES not restore its content. How to deal with it? Many webstores want/allow users to get items PRIOR the logging in, So if user got items in cart, then it gets registered and logs in all his cart items age gone, kind of disappointment...

LordotU commented 10 years ago

If you still interested for problem solving...

For the first, you need to add false parameter value to your logout method (http://www.yiiframework.com/doc/api/1.1/CWebUser#logout-detail):

Yii::app()->user->logout(false);

Next, you need to change 2 lines in EShoppingCart.php:

Line 121 to Yii::app()->session[$this->cartId] = serialize($this->toArray());

Line 36 to $data = unserialize(Yii::app()->session[$this->cartId]);

After applying of these changes, user's cart data will persist even after logging out.