wc_print_notice( string $message, string $notice_type = 'success', array $data = array() )

Print a single notice immediately.


Description Description


Parameters Parameters

$message

(Required) The text to display in the notice.

$notice_type

(Optional) The singular name of the notice type - either error, success or notice.

Default value: 'success'

$data

(Optional) notice data. @since 3.9.0.

Default value: array()


Top ↑

Source Source

File: includes/wc-notice-functions.php

function wc_print_notice( $message, $notice_type = 'success', $data = array() ) {
	if ( 'success' === $notice_type ) {
		$message = apply_filters( 'woocommerce_add_message', $message );
	}

	$message = apply_filters( 'woocommerce_add_' . $notice_type, $message );

	wc_get_template(
		"notices/{$notice_type}.php",
		array(
			'messages' => array( $message ), // @deprecated 3.9.0
			'notices'  => array(
				array(
					'notice' => $message,
					'data'   => $data,
				),
			),
		)
	);
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.