wc_notice_count( string $notice_type = '' )
Get the count of notices added, either for all notices (default) or for one.
Description Description
particular notice type specified by $notice_type.
Parameters Parameters
- $notice_type
-
(Optional) The name of the notice type - either error, success or notice.
Default value: ''
Return Return
(int)
Source Source
File: includes/wc-notice-functions.php
function wc_notice_count( $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;
}
$notice_count = 0;
$all_notices = WC()->session->get( 'wc_notices', array() );
if ( isset( $all_notices[ $notice_type ] ) ) {
$notice_count = count( $all_notices[ $notice_type ] );
} elseif ( empty( $notice_type ) ) {
foreach ( $all_notices as $notices ) {
$notice_count += count( $notices );
}
}
return $notice_count;
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.1 | Introduced. |