Jump to content

How to avoid removing cart after logout


sabreen22

Recommended Posts

Hi  :)

I need in my website to avoid removing products from the cart if user make logout .. I searched a lot about it but i didn't find any module make that .... if there isn't feature in prestashop make that how to make that from the code ... and thanks in advance  :)  :)  :)

Link to comment
Share on other sites

The problem is that once you logout, the cart will still have the id_customer of your previous session, and since the logged out one is 0, it can't be loaded. I don't think there is a simple way, unless  you want to try changing the user if only here

 

public function logout()
    {
        $this->_content = array();
        $this->_setcookie();
        unset($_COOKIE[$this->_name]);
        $this->_modified = true;
    }
  • Like 1
Link to comment
Share on other sites

This will work on all pages. THe file is classes/Cookie.php
All of that empties the cart, as it empties the current cookie. You will have to be php savvy to make the modification, as you need to unset user variables and keep the cart only

  • Like 1
Link to comment
Share on other sites

  • 8 months later...

Hi Guys,

 

I did an override on Cookie.php and commented the above line as you mentionned.

 

Unfortunately, it does seems to work...

class Cookie extends CookieCore
{
    /**
     * Delete cookie
     * As of version 1.5 don't call this function, use Customer::logout() or Employee::logout() instead;
     */
    public function logout()
    {
        $this->_content = array();
        $this->_setcookie();
        // unset($_COOKIE[$this->_name]);
        $this->_modified = true;
    }

}

Any iddea to fix that ?

Link to comment
Share on other sites

There might, so clear the class index. If you just created it it won't work otherwise. Also, if you cleared it, try to add die('test'); and see if the script dies.

Hi NemoPS,

I deleted cache_index but it does not seem to work.

 

I just added the die('test') in my Cookie.php file and nothing happen when I tried to lot out. I guess the override class is not called?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...