Automattic\WooCommerce\Blocks\BlockTypes

RelatedProducts::render_block()publicWC 1.0

If there are no related products, return an empty string.

Метод класса: RelatedProducts{}

Хуков нет.

Возвращает

Строку. The block content.

Использование

$RelatedProducts = new RelatedProducts();
$RelatedProducts->render_block( $content, $block );
$content(строка) (обязательный)
The block content.
$block(массив) (обязательный)
The block.

Код RelatedProducts::render_block() WC 9.1.2

public function render_block( string $content, array $block ) {
	if ( ! $this->is_related_products_block( $block ) ) {
		return $content;
	}

	// If there are no related products, render nothing.
	$related_products_ids = $this->get_related_products_ids();
	if ( count( $related_products_ids ) < 1 ) {
		return '';
	}

	return $content;
}