Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::getCount()
Get the count, if displaying.
Метод класса: ProductCategories{}
Хуков нет.
Возвращает
Строку
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->getCount( $category, $attributes );
- $category(объект) (обязательный)
- Term object.
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию: empty array
Код ProductCategories::getCount() ProductCategories::getCount WC 8.7.0
protected function getCount( $category, $attributes ) { if ( empty( $attributes['hasCount'] ) ) { return ''; } if ( $attributes['isDropdown'] ) { return '(' . absint( $category->count ) . ')'; } $screen_reader_text = sprintf( /* translators: %s number of products in cart. */ _n( '%d product', '%d products', absint( $category->count ), 'woocommerce' ), absint( $category->count ) ); return '<span class="wc-block-product-categories-list-item-count">' . '<span aria-hidden="true">' . absint( $category->count ) . '</span>' . '<span class="screen-reader-text">' . esc_html( $screen_reader_text ) . '</span>' . '</span>'; }