Get orders with free items I have a pricing rule to do some items free.
User can purchase only 3 items per month.

Question is how to programmatically get count of free items purchased by user?
I needed to do something vaguely similar the other day and the only way I could find was to go into the db tables directly to grab the data. The problem is you need to join the line item and orders tables (for the order status), which you can't do with (for example) an EntityFieldQuery.

I think you'd be looking for a query simliar to:

SELECT SUM(li.quantity)
FROM {commerce_order} o 
INNER JOIN commerce_line_item li ON li.order_id = o.order_id
WHERE o.status = :status
AND li.line_item_label = :sku
AND order.uid = :uid


But it'll probably need some tweaking for your needs (to get results for orders created between certain dates for example).