ramin Posted January 21, 2013 Share Posted January 21, 2013 (edited) I have Disabled ajax on my shopping cart moudle I want to edit prestashop 1.4.9 for purpose allow only one product at time in cart details I need help how to do it and which changes must be applied. Edited January 21, 2013 by ramin (see edit history) Link to comment Share on other sites More sharing options...
maciekmaster Posted July 8, 2013 Share Posted July 8, 2013 I need the same solution. The customer can select a product and then just the same to cart. Only after placing the order may select a different product. Is there a module or solution? Link to comment Share on other sites More sharing options...
jaimeweb Posted October 9, 2013 Share Posted October 9, 2013 Hi, Can anyone advise how to do this? I simply want to restrict customers to add more than 1 product to their cart. If they try to add multiple items some sort of warning/message comes up. Please help! Link to comment Share on other sites More sharing options...
jaimeweb Posted October 10, 2013 Share Posted October 10, 2013 Anyone? Link to comment Share on other sites More sharing options...
jaimeweb Posted October 12, 2013 Share Posted October 12, 2013 Bump Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted October 14, 2013 Share Posted October 14, 2013 You need to override controller file CartController.php , public function preProcess(). e.g : public function preProcess() { if(count(self::$cart->getProducts) > 1) $this->errors[] = Tools::displayError('Sorry only 1 product allowed to be purchased'); else parent::preProcess(); } Link to comment Share on other sites More sharing options...
jaimeweb Posted October 14, 2013 Share Posted October 14, 2013 Hi Thanks for your reply. How do I implement this into the CartController? Where should it go or replace? Thanks Link to comment Share on other sites More sharing options...
vekia Posted October 14, 2013 Share Posted October 14, 2013 in your prestashop filesystem in directory /controllers/ you've got file CartController.php path: /controllers/CartController.php inside this function you've got function: public function preProcess(), use there code mentioned above, Link to comment Share on other sites More sharing options...
jaimeweb Posted October 14, 2013 Share Posted October 14, 2013 I cannot find any reference to "public function preProcess()" in CartController.php. I am on 1.5.5 Link to comment Share on other sites More sharing options...
jaimeweb Posted October 15, 2013 Share Posted October 15, 2013 Hi vekia, any chance you could help me find where to put this on 1.5.5? Thanks again for your help! Link to comment Share on other sites More sharing options...
vekia Posted October 15, 2013 Share Posted October 15, 2013 open file:/controllers/CartController.php there is function postProcess(); use this one: public function postProcess(){// Update the cart ONLY if $this->cookies are available, in order to avoid ghost carts created by botsif ($this->context->cookie->exists() && !$this->errors && !($this->context->customer->isLogged() && !$this->isTokenValid())){if (Tools::getIsset('add') || Tools::getIsset('update')){if(count($this->context->cart->getProducts()) >= 1)$this->errors[] = Tools::displayError('Sorry only 1 product allowed to be purchased');else$this->processChangeProductInCart();}else if (Tools::getIsset('delete'))$this->processDeleteProductInCart();else if (Tools::getIsset('changeAddressDelivery'))$this->processChangeProductAddressDelivery();else if (Tools::getIsset('allowSeperatedPackage'))$this->processAllowSeperatedPackage();else if (Tools::getIsset('duplicate'))$this->processDuplicateProduct();// Make redirectionif (!$this->errors && !$this->ajax){$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 pageif (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');} effect: Link to comment Share on other sites More sharing options...
abugroup Posted June 13, 2014 Share Posted June 13, 2014 (edited) open file:/controllers/CartController.php there is function postProcess(); use this one: effect: Hi, thank you for this solution But in Prestashop 1.6 it does not showing any message can you give any solution about this thankyou vekia Edited June 13, 2014 by abugroup (see edit history) Link to comment Share on other sites More sharing options...
ZiedDams Posted February 21, 2022 Share Posted February 21, 2022 any updates for 1.7 ? 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