woothemes/woocommerce — pull request #2468 by krbvroc1 (2013-02-18 19:12:13+00:00)
Title: Allow user error message on filtered invalid coupon error messages

Allow user error message on filtered invalid coupon error messages There was a way to do this previously, but #2456 broke that method.

Here is the user case/problem.

In WC_Coupon::is_valid(), there is the woocommerce_coupon_is_valid' filter.
When that filter returns invalid, there needs to be a way for the user to provide a coupon_error message. This patch introduces a E_WC_COUPON_INVALID_FILTERED error_code which the 'woocommerce_coupon_error' filter can use to provide the error.

Calling add_error directly in the 'woocommerce_coupon_is_valid' is not a good idea because is_valid() get invokes about 5-10 times during the apply coupon process.