Thanks KGT for the great contribution!
It was all working perfectly until I installed other discounts to my shop (2gether and category discounts). Now when using a coupon code, it calculates the discount from the full price, and then subtracts this from the already discounted price. This results in the customer getting a much bigger discount than the coupon is worth.
I'm new to PHP so am hoping someone can help me with this :'( Is it possible for the discount coupon to be applied to the subtotal after any other discounts, (the value that would otherwise be the total if not using a coupon), rather than the sum of the full priced products, which I think is how it is currently calculated?