The code that I posted was an example of what a calculation would look like for this. Calculations are columns in the cart that are calculated rather than assigned a value in the add to cart.
The different between doing things with calculations and discounts is that calculations on a line item basis. The idea with the calculation posted is that you will accumulate the total amount to discount for each item in the cart into a new calculated column. This way your discount rule will be very simple, it will just be based on the subtotal of this new calculated column.
You add calculations into the cart object through the calculations tab.