Jump to content

Set Limit product on cart


30ml
 Share

Recommended Posts

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More