edit: downvoted, sigh. ok. I'll elaborate. When you give me a discount code field on your checkout page, I automatically open up a new tab and Google around for "your site name discount code". If I can find one that works, you're just losing money for absolutely no good reason. I would've happily checked out without ever thinking of saving 5% on my $50 purchase. (c'mon, $2.50? That's not even a latte!) But, now, I'm obsessed, and I go back into 'bargain hunter' mode. If you're really unlucky, I'll find another site that undercuts you without a discount field, and just use them.
Save yourself the trouble. Apply a coupon via a cookie from a special landing page. I'll feel excited and grateful if one is applied for me at checkout and I won't even think of shopping around any more if I don't have one.
Affiliates will call after the sale asking to proactively apply discount codes (so they get credit).
Customers will complain if a discount code has expired.
Customers will cancel, return and re-buy just to apply discount codes.
Discount codes suck.