The sales team are looking for a way to restrict a customer to a maximum order quantity for a product per order, at header level not line level. This needs to be at customer / product level. Has anyone come across this type of requirement?

The sales team are looking for a way to restrict a customer to a maximum order quantity for a product per order, at header level not line level. This needs to be at customer / product level. Has anyone come across this type of requirement?
I guess you can make a count field on the main form which will indicate the total number of the product which are already ordered.
You will need a custom code which will run, When a sales person will create/update a product order with the new line then you can run your code before save and show a warning as "Max Order" if it passes the limit else save the record and update the count field on the main form.