wc_print_notice

Print a single notice immediately.

Description

wc_print_notice( (string) $message, (string) $notice_type = 'success' ); 

Parameters (2)

0. $message (string)
The text to display in the notice.
1. $notice_type — Optional. (string) => 'success'
The singular name of the notice type - either error, success or notice. [optional]

Usage

  1. if ( !function_exists( 'wc_print_notice' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-notice-functions.php'; 
  3.  
  4. // The text to display in the notice. 
  5. $message = ''; 
  6.  
  7. // The singular name of the notice type - either error, success or notice. [optional] 
  8. $notice_type = 'success'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_print_notice($message, $notice_type); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-notice-functions.php  
  1. function wc_print_notice( $message, $notice_type = 'success' ) { 
  2. if ( 'success' === $notice_type ) { 
  3. $message = apply_filters( 'woocommerce_add_message', $message ); 
  4.  
  5. wc_get_template( "notices/{$notice_type}.php", array( 
  6. 'messages' => array( apply_filters( 'woocommerce_add_' . $notice_type, $message ) ),  
  7. ) );