Author Topic: One order per customer  (Read 454 times)

Offline Claudio Garcia

  • Newbie
  • *
  • Posts: 35
  • Karma: +7/-0
    • View Profile
One order per customer
« on: October 17, 2019, 09:00:48 AM »
Hi

Where i find code information to restrict a customer to make one order per day and to restring customer registration to one domain .example.com mail accounts only.


Thanks




Offline dvagner

  • Core/UI Developer
  • Newbie
  • *
  • Posts: 34
  • Karma: +13/-0
    • View Profile
Re: One order per customer
« Reply #1 on: October 18, 2019, 02:29:34 AM »
You can check exists orders in Cart Controller Hook: storefront/controller/pages/checkout/cart.php:26
for check email registration create hook for Registartion Controller: storefront/controller/pages/account/create.php:24

Offline Julian Marcelo

  • Newbie
  • *
  • Posts: 10
  • Karma: +2/-0
    • View Profile
Re: One order per customer
« Reply #2 on: October 19, 2019, 01:33:12 AM »
Hello dvagner

Where i can find some help to modify the cart.php to query for orders? Do you know the tablet name, idorder column name and product table?

Please help me a little bit more, i need some adittional help.
« Last Edit: October 19, 2019, 01:35:27 AM by Julian Marcelo »

Offline Claudio Garcia

  • Newbie
  • *
  • Posts: 35
  • Karma: +7/-0
    • View Profile
Re: One order per customer
« Reply #3 on: October 19, 2019, 04:37:28 AM »
Yes

I didnt understand very well. Its like when you to a restaurant and they serve a litte bit, you say "I need more carnita" "i want more meat"

Offline Claudio Garcia

  • Newbie
  • *
  • Posts: 35
  • Karma: +7/-0
    • View Profile
Re: One order per customer
« Reply #4 on: October 21, 2019, 06:45:05 AM »
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?

     
Code: [Select]
      $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
           
« Last Edit: October 30, 2019, 04:02:55 AM by Claudio Garcia »

Offline Julian Marcelo

  • Newbie
  • *
  • Posts: 10
  • Karma: +2/-0
    • View Profile
Re: One order per customer
« Reply #5 on: October 22, 2019, 04:30:35 AM »
Someone please explain how to do it? I really dont understad what Claudio explain

 

Powered by SMFPacks Social Login Mod