Automattic\WooCommerce\Blocks\BlockTypes

ProductFilterStockStatus::render()protectedWC 1.0

Include and render the block.

Method of the class: ProductFilterStockStatus{}

No Hooks.

Return

String. Rendered block type output.

Usage

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

ProductFilterStockStatus::render() code WC 9.4.2

protected function render( $attributes, $content, $block ) {
	// don't render if its admin, or ajax in progress.
	if ( is_admin() || wp_doing_ajax() ) {
		return '';
	}

	$stock_status_counts = $this->get_stock_status_counts( $block );
	$wrapper_attributes  = get_block_wrapper_attributes(
		array(
			'data-has-filter' => empty( $stock_status_counts ) ? 'no' : 'yes',
		)
	);

	return sprintf(
		'<div %1$s>%2$s</div>',
		$wrapper_attributes,
		$this->get_stock_filter_html( $stock_status_counts, $attributes ),
	);
}