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:
parent
25944c9086
commit
9f3ae48b8f
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue