fra_000111 Posted January 27, 2023 Share Posted January 27, 2023 Hello, i have a strange problem, when opening a product page in incognito mode (so that there is no cache, cookie etc.. loaded) and i try to add to cart a product it dont work the first time add to cart button is clicked but only after page is reloaded. Note that if the user navigate other pages before trying to add to cart it work. To reproduce open an incognito page and directly go to a product page like https://bikenos.com/it/copertoni/28040-copertone-12-x12x2-14-57-203-nero-c1456-6933882509092.html Try to add to cart and the product is not added, ajax cart show 0 product added. If now you try to go in every other products and add to cart it work. Could this be some cookie related problem? Link to comment Share on other sites More sharing options...
Prestachamps Posted January 27, 2023 Share Posted January 27, 2023 Hi @fra_000111, yes, most probably it is a cookie issue there, as somehow the first add to cart is creating the cookie on the shop, and for the second add to cart, the cookie exitsts and it is working. Do you have some cookie module like lgcookieslaw module? as I see that odule in the code, but the module's popup is not shown on pageload. Can you try to disable that module and check if this solves the issue? I hope that I could help. Have a nice day, Leo. 1 Link to comment Share on other sites More sharing options...
fra_000111 Posted January 27, 2023 Author Share Posted January 27, 2023 Hi, thank for the response. i tried disabling the cookies manager module and in fact it work! Now i only have to find a way to make it work while activated. Thanks! Link to comment Share on other sites More sharing options...
fra_000111 Posted January 27, 2023 Author Share Posted January 27, 2023 Also found partial solution for the cookie problem, basically in the controllers > front > cartcontrollers.php file at line 238 there is a control that check if cookies exist, having the cookie module activated mean that a user when enter the website for the first time, the first page he see dont have cookies so the "if" instruction will block the "add to cart" function. A solution is to edit the code at line 239 to: // Update the cart ONLY if $this->cookies are available, in order to avoid ghost carts created by bots if (!$this->errors && !($this->context->customer->isLogged() && !$this->isTokenValid()) ) Note that in this way also bots will be able to create carts. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now