Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
NoResults::render()
Render the block.
Method of the class: NoResults{}
No Hooks.
Return
String
. | void 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.
NoResults::render() NoResults::render code WC 9.6.1
protected function render( $attributes, $content, $block ) { $content = trim( $content ); if ( empty( $content ) ) { return ''; } $query = ProductCollectionUtils::prepare_and_execute_query( $block ); // If the query has products, don't render the block. if ( $query->post_count > 0 ) { return ''; } // Update the anchor tag URLs. $updated_html_content = $this->modify_anchor_tag_urls( trim( $content ) ); $wrapper_attributes = get_block_wrapper_attributes(); return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $updated_html_content ); }