wc_notice_count()
Get the count of notices added, either for all notices (default) or for one. particular notice type specified by $notice_type.
Хуков нет.
Возвращает
int
.
Использование
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 9.8.2
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 ] ) && is_array( $all_notices[ $notice_type ] ) ) { $notice_count = count( $all_notices[ $notice_type ] ); } elseif ( empty( $notice_type ) ) { foreach ( $all_notices as $notices ) { if ( is_countable( $notices ) ) { $notice_count += count( $notices ); } } } return $notice_count; }