WC_Coupon::add_coupon_message()
Converts one of the WC_Coupon message/error codes to a message string and. displays the message/error.
Method of the class: WC_Coupon{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_Coupon = new WC_Coupon(); $WC_Coupon->add_coupon_message( $msg_code, $notice_type );
- $msg_code(int) (required)
- Message/error code.
- $notice_type(string)
- Notice type.
Default: 'success'
WC_Coupon::add_coupon_message() WC Coupon::add coupon message code WC 9.4.2
public function add_coupon_message( $msg_code, $notice_type = 'success' ) { if ( $msg_code < 200 ) { $msg = $this->get_coupon_error( $msg_code ); $notice_type = 'error'; } else { $msg = $this->get_coupon_message( $msg_code ); } if ( empty( $msg ) ) { return; } // Since coupon validation is done multiple times (e.g. to ensure a valid cart), we need to check for dupes. if ( wc_has_notice( $msg, $notice_type ) ) { return; } wc_add_notice( $msg, $notice_type ); }