How can I limit the client to only buy 4 products per month.

For example I have product A, B, C, D and E.

The costumer makes an order and puts in the cart product A,B and C.

In the same month the costumer can only put in cart product A,B,C and D or E. But not D,E and A. Because the costumer already ordered product A,B and C and he can only buy 4 products per month. The next month he can make an order with A,B,D,E , but in the same month he can only buy one of those 4 and he won't be able to buy the other one. How can I do that ?

I got this

    $orders = Mage::getResourceModel('sales/order_collection')
    ->addFieldToSelect('*')
    ->addFieldToFilter('customer_id', $customer->getId())
    ->addAttributeToSelect('created_at')
    ->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to))
    ->load();

to get the orders, but how can I find the products purchased so I can check if he putted any product in the cart the he shouldn't ?

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top