wc_get_notices()WC 2.1

Returns all queued notices, optionally filtered by a notice type.

No Hooks.

Return

Array[].

Usage

wc_get_notices( $notice_type );
$notice_type(string)
The singular name of the notice type - either error, success or notice.
Default: ''

Changelog

Since 2.1 Introduced.

wc_get_notices() code WC 8.6.1

function wc_get_notices( $notice_type = '' ) {
	if ( ! did_action( 'woocommerce_init' ) ) {
		wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' );
		return;
	}

	$all_notices = WC()->session->get( 'wc_notices', array() );

	if ( empty( $notice_type ) ) {
		$notices = $all_notices;
	} elseif ( isset( $all_notices[ $notice_type ] ) ) {
		$notices = $all_notices[ $notice_type ];
	} else {
		$notices = array();
	}

	return $notices;
}