Automattic\WooCommerce\Admin\Features

TransientNotices::add()public staticWC 1.0

Add a notice to be shown.

Method of the class: TransientNotices{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = TransientNotices::add( $notice );
$notice(array) (required)
Notice.
php $notice = array( 'id' => (string) Unique ID for the notice. Required. 'user_id' => (int|null) User ID to show the notice to. 'status' => (string) info|error|success 'content' => (string) Content to be shown for the notice. Required. 'options' => (array) Array of options to be passed to the notice component. See https://developer.wordpress.org/block-editor/reference-guides/data/data-core-notices/#createNotice for available options. ).

TransientNotices::add() code WC 8.7.0

public static function add( $notice ) {
	$queue = self::get_queue();

	$defaults               = array(
		'user_id' => null,
		'status'  => 'info',
		'options' => array(),
	);
	$notice_data            = array_merge( $defaults, $notice );
	$notice_data['options'] = (object) $notice_data['options'];

	$queue[ $notice['id'] ] = $notice_data;
	update_option( self::QUEUE_OPTION, $queue );
}