How to create a Promotion based on basket item quantity

How to create a Rule so that for each item in the basket with certain tag, the user will get a discount for a certain about.

Example:

If there are 3 units of 1 item with tag „abc“ and 2 units of another item with tag „abc“, then he will get (3+2) times 2$ discount, so 5*2=10$ discount.

I did a research and want to share my findings.

It seems that in GoodsCountRule.php they forgot to count the number of same items. They only count the different products. It can be fixed by multiplying the item quantity for each item.