Reputation: 4506
I want to limit customers to buy only three products, and the total quantity should be three only. Conditions:
1st condition:
product1-> 1
product2-> 1
product3-> 1
total qty is 3 here.
2nd condition:
product1-> 2
product3->1
total qty is 3 here.
3rd condition:
product1-> 3
total qty is 3 here.
How to limit cart section like this in opencart ?
Upvotes: 3
Views: 3566
Reputation: 5211
Parin Order Quantity Limit for minimum and maximum order limit on cart
You can manage limit orders to cart from admin panel.
if your limit greater product on cart not checkout the order.
Upvotes: 2
Reputation: 3616
Are you looking for the code changes that do this?
If so, then I would advise coding in catalog/controller/checkout/cart.php early in the add() function
$cart_products = $this->cart->getProducts();
$cart_quantity = 0;
foreach ($cart_products as $cart_product)
$cart_quantity += $cart_product['quantity'];
if (($cart_quantity + (int)$this->request->post['quantity']) > 3)
$json['error'] = $this->language->get('error_cart_full');
That code isn't tested by the way, and obviously I've hard-coded the 3. Also you may have to put something in the tpl of the page you're adding from to actually display the error.
Upvotes: 2