Max Orders Per Customer Per Day

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi, Earthlings,

Is there any plugin that will prevent the customer from ordering more than (x) products in a 24-hour period and if not can someone point me to the area in the project code where I can implement this myself?

many thanks in advance,

Paul.
4 years ago
Create a new settings, where you can save a number which will define the maximum number of orders a customer can place in 24 hour.

Check in PlaceOrder method (in OrderProcessingService class) whether customer has already placed that number of orders in last 24 hour or not.
4 years ago
I just added this in the ConfirmOrder method, it's quick and dirty with a hard-coded value, but does the job. As you can see I am not a NOP developer.


// ClickAlgo - limit free orders to 10 a day.
var customer = _workContext.CurrentCustomer;
var orderItems = _orderService.GetDownloadableOrderItems(customer.Id);
int todaysOrders = orderItems.Where(x => (x.PriceInclTax == 0)).Where(x => x.Order.CreatedOnUtc.Date == DateTime.UtcNow.Date).Count();

if (todaysOrders >= 10)
{
   model.Warnings.Add("You have reached your daily quota of 10 free orders per day, please return tomorrow to order more products.");
   return View(model);
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.