Jump to content

Cart Product Limit


Recommended Posts

Hey there,


I'm trying to limit number of the products for each shopping cart. I wrote a override for my module which is : 



 * 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 :



Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...