mertakdeniz Posted July 23, 2015 Share Posted July 23, 2015 Hey there, I'm trying to limit number of the products for each shopping cart. I wrote a override for my module which is : /modules/mymodule/override/controllers/front/CartController.php <?php /** * Created by PhpStorm. * User: mert akdeniz * Date: 22.07.2015 * Time: 14:37 */ class CartController extends CartControllerCore { public function processChangeProductInCart() { if ($this->context->cart->nbProducts() == 1){ $this->errors[] = Tools::displayError('You can not add more than 1 quantity in cart.'); } } } I did it but it just disable adding any product to the cart (even cart is empty), What am I missing? My PS version : 1.6.1.0 Thanks. Link to comment Share on other sites More sharing options...
bellini13 Posted July 23, 2015 Share Posted July 23, 2015 your logic says that it the number of products in the cart is equal to 1, then show an error. That will prevent any products from being added to the cart. Instead, try saying if the number of products in the cart is greater than 1 Link to comment Share on other sites More sharing options...
mertakdeniz Posted July 23, 2015 Author Share Posted July 23, 2015 I think I didn't state myself clearly. I tried to change number to 10, but even cart is empty (i mean 0 products on cart), nothing happening when I click "add to cart" button. Not adding product to the cart. I just want to do, if i set limit as 3, after 3rd product when user try to add new product to the cart, a message says "you can't". Link to comment Share on other sites More sharing options...
bellini13 Posted July 24, 2015 Share Posted July 24, 2015 then you need to debug this further. I assume you are using ajax cart, so you will need to review the http response after clicking the add to cart button and see what response is being returned. 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