30ml Posted September 17, 2013 Share Posted September 17, 2013 hi, I am hang on ajax stuff. Normally user click on add to cart button to add into cart. But I want to stop to add product in cart once cart have 1 quantity . So, what would be the process.Is is necessary to scratch cart controller and manage it in override folder ? Is it good idea ? if not what would be the next idea ? Thanks Link to comment Share on other sites More sharing options...
vekia Posted September 17, 2013 Share Posted September 17, 2013 you want to prevent to add more than the 1 product to cart? or to prevent to add more products (no matter what product) to cart? Link to comment Share on other sites More sharing options...
30ml Posted September 17, 2013 Author Share Posted September 17, 2013 I want to prevent more than 1 product in cart. Here, I solve my problem by putting below code in Cartcontroller.php on processChangeProductInCart method if ($this->context->cart->nbProducts() == 1){ $this->errors[] = Tools::displayError('You can not add more than 1 quantity in cart.'); } Most probably, I will put this file in overrise/controller/front. Can I do such control from my customize module ? you want to prevent to add more than the 1 product to cart? or to prevent to add more products (no matter what product) to cart? Link to comment Share on other sites More sharing options...
30ml Posted September 17, 2013 Author Share Posted September 17, 2013 now user can not put more than one product in a cart. But I am finding solution if I can do through my module. I want to prevent more than 1 product in cart. Here, I solve my problem by putting below code in Cartcontroller.php on processChangeProductInCart method if ($this->context->cart->nbProducts() == 1){ $this->errors[] = Tools::displayError('You can not add more than 1 quantity in cart.'); } Most probably, I will put this file in overrise/controller/front. Can I do such control from my customize module ? 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