ayin Posted February 19, 2015 Share Posted February 19, 2015 (edited) Hello, I wanted to change the default behavior of "Add to Cart" buttons so it doesn't show the popup with [Continue Shopping] and [Finalize purchase] options, but rather stay on same page (Product.tpl or ProductList.tpl) and do an Ajax Refresh to update de Top right Cart (module?) quantities and in-page product availability. I started looking into the file "prestashop\htdocs\controllers\front\CartController.php" and in line 67~103: and wish to test this code in order to understand how I can make the change described above. // Make redirection if (!$this->errors && !$this->ajax) { echo 'hi'; $queryString = Tools::safeOutput(Tools::getValue('query', null)); if ($queryString && !Configuration::get('PS_CART_REDIRECT')) Tools::redirect('index.php?controller=search&search='.$queryString); // Redirect to previous page if (isset($_SERVER['HTTP_REFERER'])) { if (isset($regs[3]) && !Configuration::get('PS_CART_REDIRECT')) Tools::redirect($_SERVER['HTTP_REFERER']); } Tools::redirect('index.php?controller=order&'.(isset($this->id_product) ? 'ipa='.$this->id_product : '')); } } elseif (!$this->isTokenValid()) Tools::redirect('index.php'); Any hints? : ) Edited February 19, 2015 by ayin (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted February 19, 2015 Share Posted February 19, 2015 go to the modules page, and search for the "cart block" module and then click configure. Change the "ajax cart" setting to "no" and save Then go to the preferences > product page in the back office, and change the "redirect after adding product to cart" setting to "previous page" 1 Link to comment Share on other sites More sharing options...
ayin Posted February 19, 2015 Author Share Posted February 19, 2015 Hey bellini13, but this way I won't lose the ajax Cart? I mean, each time I add an product will I refresh (HTTP POST) the product-list page? It will slow down the user experience, no? Thanks for your input go to the modules page, and search for the "cart block" module and then click configure. Change the "ajax cart" setting to "no" and save Then go to the preferences > product page in the back office, and change the "redirect after adding product to cart" setting to "previous page" Link to comment Share on other sites More sharing options...
bellini13 Posted February 20, 2015 Share Posted February 20, 2015 The entire page will refresh, ajax will not be used. 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