Automattic\WooCommerce\Blocks\BlockTypes

ProductResultsCount::render │ protected │ WC 1.0

Render the block.

Method of the class: ProductResultsCount{}

No Hooks.

Returns

string. Rendered block output.

Usage

// protected - for code of main (parent) or child class
$result = $this->render( $attributes, $content, $block );
$attributes(array) (required)
Block attributes.
$content(string) (required)
Block content.
$block(WP_Block) (required)
Block instance.

ProductResultsCount::render() code WC 11.3.0

protected function render( $attributes, $content, $block ) {
	// Buffer the result count and use it as the block's frontend content.
	ob_start();
	woocommerce_result_count();
	$product_results_count = ob_get_clean();

	$classes = 'woocommerce wc-block-product-results-count';
	if ( ! empty( $attributes['fontSize'] ) ) {
		// Preserve the legacy class for backward compatibility.
		$classes .= ' has-font-size';
	}

	$wrapper_attributes = get_block_wrapper_attributes(
		array(
			'class'                 => $classes,
			'data-wp-interactive'   => $this->get_full_block_name(),
			'data-wp-router-region' => 'wc-product-results-count-' . ( $block->context['queryId'] ?? 0 ),
		)
	);

	return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $product_results_count );
}