Balaji Kandasamy
Balaji Kandasamy

Reputation: 4506

How to limit orders to cart in Opencart?

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

Answers (2)

Ravi Patel
Ravi Patel

Reputation: 5211

Parin Order Quantity Limit for minimum and maximum order limit on cart

  1. You can manage limit orders to cart from admin panel.

  2. if your limit greater product on cart not checkout the order.

enter image description here enter image description here

Upvotes: 2

komodosp
komodosp

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

Related Questions