Automattic\WooCommerce\Blocks\BlockTypes
ProductDetails::render
Render the block.
Method of the class: ProductDetails{}
Hooks from the method
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.
ProductDetails::render() ProductDetails::render code WC 10.5.0
protected function render( $attributes, $content, $block ) {
if ( empty( $block->parsed_block['innerBlocks'] ) ) {
return $this->render_legacy_block( $attributes, $content, $block );
}
$parsed_block = $block->parsed_block;
$parsed_block = $this->hide_empty_accordion_items( $parsed_block, $block->context );
/**
* Filter to disable the compatibility layer for the blockified templates.
*
* @see AddToCartWithOptions::render() for full documentation.
* @since 7.6.0
*/
if ( ! apply_filters( 'woocommerce_disable_compatibility_layer', false ) ) {
$parsed_block = $this->inject_compatible_tabs( $parsed_block );
}
$inner_content = array_reduce(
$parsed_block['innerBlocks'],
function ( $carry, $parsed_inner_block ) use ( $block ) {
$carry .= ( new \WP_Block( $parsed_inner_block, $block->context ) )->render();
return $carry;
},
''
);
return sprintf(
'<div %1$s>%2$s</div>',
get_block_wrapper_attributes(),
$inner_content
);
}