Skip coupon notices if there's no message

Handy for defining programmatic coupons to apply cart discounts, when
you wouldn't necessarily want to have a notice displayed
This commit is contained in:
justinstern 2015-03-06 00:36:01 -05:00
parent 25944c9086
commit 9f3ae48b8f
1 changed files with 9 additions and 3 deletions

View File

@ -656,13 +656,19 @@ class WC_Coupon {
* displays the message/error.
*
* @param int $msg_code Message/error code.
* @return void
*/
public function add_coupon_message( $msg_code ) {
$msg = $this->get_coupon_error( $msg_code );
if ( ! $msg ) {
return;
}
if ( $msg_code < 200 ) {
wc_add_notice( $this->get_coupon_error( $msg_code ), 'error' );
wc_add_notice( $msg, 'error' );
} else {
wc_add_notice( $this->get_coupon_message( $msg_code ) );
wc_add_notice( $msg );
}
}