Jump to content

Cart not empty after logout


Carpe_diem

Recommended Posts

Hi guys,

I have a problem with a Prestashop 1.6.1.5 of my client and the shopping cart is problem. The thing is when I login and add a product to my cart everythings works as it should. I go to the checkout page and decide to logout. The log out works but the problem is that the cart icon is showing 0 products but the added product is still showing in my cart. The next thing is that I can't delete the product or log in again. The funny part is when I change the page and add another product and go to the checkout the first product isn't there anymore and everything works as it should.

The console doesn't show any errors and honestly I don't know how to solve this problem.  I tried to add some code like  $this->context->cart->delete(); and unset($this->_content['id_cart']); to classes/Cookie.php in the logout function but it didn't work. Has anyone had similar problems and what was the solution.

Best regards.

Link to comment
Share on other sites

13 hours ago, Prestachamps said:

Hi, 

 

Not sure if that's the reason, however check the preferences section clients, and try to disable the keep cart option on login. Delet the site cache after, and finger crossed it will solve the issue ;) 

I hope it helps, 

Cheers, 

Leo

Tried and it still doesn't solve the problem. I created a delete all clause when clicking on log out I added a clear cart code like this:

Cart Controller

elseif (Tools::getIsset('deleteAll')) {
                 
    $this->context->cart->delete();
    $this->context->cookie->id_cart = 0;
}

global.js

 $('#header_links .logout').click(function(e) {
        e.preventDefault()
        $.ajax({
            type: 'POST',
             headers: { "cache-control": "no-cache" },
             url: baseUri + '?rand=' + new Date().getTime(),
             async: true,
             cache: false,
             dataType : "json",
             data: 'controller=cart&deleteAll=1&token=' + static_token + '&ajax=true',
             success: function(data){
                 $('.opc-main-block, .step-num, #HOOK_SHOPPING_CART_EXTRA').fadeOut('fast');
                 $('#order-detail-content').fadeOut('fast', function() {
                     $('#emptyCartWarning').fadeIn('slow');  
                });
                 ajaxCart.refresh();
				 window.location.href = "https://mystore.com/en/?mylogout=";
            }
         })
    });

Here comes the funny part it clears the shopping cart and says the shopping cart is empty and logs out. When I click on the shopping cart is the product still in the cart and can't be deleted. After this try I am out of ideas because it doesn't make any sense.

 

Link to comment
Share on other sites

15 hours ago, Mediacom87 said:

Hi,

By chance, on your store, don't you use a CDN or a caching system, or in the Performance page of your backoffice, don't you have activated the server cache at the bottom of this page, or even worse, don't you use a caching module in addition.

No CDNs are used and no caching system is active. My last try is above and I am seriously out of ideas.

Link to comment
Share on other sites

Hi,

you can try to check from the Backoffice the shopping carts, an delete them, as probably your cart is bugged.

Also  you can try the following:

Open the shop in a new incognito window and try to add to cart the same product which is bugged in your cart. Then try to remove it from cart in the incognito window.

I hope that I could help.
Have a nice day, Leo.

Link to comment
Share on other sites

7 minutes ago, Prestachamps said:

Hi,

you can try to check from the Backoffice the shopping carts, an delete them, as probably your cart is bugged.

Also  you can try the following:

Open the shop in a new incognito window and try to add to cart the same product which is bugged in your cart. Then try to remove it from cart in the incognito window.

I hope that I could help.
Have a nice day, Leo.

I think you might be right that the cart is bugged, because it doesn't matter which product I add to the cart the result is the same. Or it could be some cache or cookie problem as it doesn't get cleared when the cart is cleared.

Edited by Carpe_diem (see edit history)
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...