wc_notice_count() WC 2.1
Get the count of notices added, either for all notices (default) or for one. particular notice type specified by $notice_type.
Хуков нет.
Возвращает
Число.
Использование
wc_notice_count( $notice_type );
- $notice_type(строка)
- The name of the notice type - either error, success or notice.
Список изменений
С версии 2.1 | Введена. |
Код wc_notice_count() wc notice count WC 5.0.0
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;
}