Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::getCount() protected WC 1.0
Get the count, if displaying.
{} Это метод класса: ProductCategories{}
Хуков нет.
Возвращает
Строку
. Null. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->getCount( $category, $attributes );
- $category(объект) (обязательный)
- Term object.
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию: empty array
Код ProductCategories::getCount() ProductCategories::getCount WC 5.2.1
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>';
}