wc_print_notices

Prints messages and errors which are stored in the session, then clears them.

Description

wc_print_notices(); 

Usage

  1. if ( !function_exists( 'wc_print_notices' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-notice-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wc_print_notices(); 
  7.  

Defined (1)

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

/includes/wc-notice-functions.php  
  1. function wc_print_notices() { 
  2. if ( ! did_action( 'woocommerce_init' ) ) { 
  3. wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', woocommerce ), '2.3' ); 
  4. return; 
  5.  
  6. $all_notices = WC()->session->get( 'wc_notices', array() ); 
  7. $notice_types = apply_filters( 'woocommerce_notice_types', array( error, 'success', 'notice' ) ); 
  8.  
  9. foreach ( $notice_types as $notice_type ) { 
  10. if ( wc_notice_count( $notice_type ) > 0 ) { 
  11. wc_get_template( "notices/{$notice_type}.php", array( 
  12. 'messages' => array_filter( $all_notices[ $notice_type ] ),  
  13. ) ); 
  14.