How To Modify or Override Cart Functionality In An Upgrade Safe Manner

I want to override the default behavior when a coupon is entered and evaluated. If it fails to match a valid coupon I want to do something special. I have tracked the place where this happens in the code down to fn.promotions.php. What I don't know is how I can make the change in such a way that if we upgrade the cs-cart software that I don't have to add my code changes back because they were overridden.

I know this is probably cs-cart development 101, but I'm not familiar with it so please bear with me. I don't expect any elaborate response, just some key terms I can research, URLs to cs-cart docs, etc.