What i need is to block customer who orders more than 3 quantity for every product, not per order, Per customer.
I was thinking to block customer to make one order. But its better customer makes orders who they want but restrict only 3 products quantity per each product per all orders. I know is not logical rule but its a requeriment.
I checked exists orders in Cart Controller Hook: storefront/controller/pages/checkout/cart.php:260 line
I did the following change but not working:
Where i can check that?
$cart_products = $this->cart->getProducts();
$product_ids = array();
foreach ($cart_products as $result) {
$product_ids[] = (int)$result['product_id'];
$query = $this->db->query("SELECT sum(ac_order_products.quantity)
FROM ".$this->db->table('ac_order_products')" INNER JOIN ".$this->db->table('ac_orders'). ON ac_orders.order_id = ac_order_products.order_id"
WHERE o.customer_id = '".(int)$this->config->get('customer_id')."'
AND od.product_id = '".$result['product_id']."')");
if (!$query) {
$error_msg[] = "Could not run query: " . mysql_error();
exit;
}
$row = mysql_fetch_row($query);
if ($row[0] > 3) {
$error_msg[] = "You can buy only 3 units from a product in all your orders ......" .$result['name'];
}
My problem is iam not good in php.
Please help check if this is ok and where i cant get the customer id in cart.php