Automattic\WooCommerce\Blocks\BlockTypes
RelatedProducts::render_block
If there are no related products, return an empty string.
Method of the class: RelatedProducts{}
No Hooks.
Returns
String. The block content.
Usage
$RelatedProducts = new RelatedProducts(); $RelatedProducts->render_block( $content, $block );
- $content(string) (required)
- The block content.
- $block(array) (required)
- The block.
RelatedProducts::render_block() RelatedProducts::render block code WC 10.6.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;
}