Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce\Renderer\Blocks
Product_Collection::render_product_template
Render the product template block.
Метод класса: Product_Collection{}
Хуков нет.
Возвращает
Строку.
Использование
// private - только в коде основоного (родительского) класса $result = $this->render_product_template( $inner_block, $query, $collection_type ): string;
- $inner_block(массив) (обязательный)
- Inner block data.
- $query(WP_Query) (обязательный)
- WP_Query object.
- $collection_type(строка) (обязательный)
- Collection type identifier.
Код Product_Collection::render_product_template() Product Collection::render product template WC 10.4.3
private function render_product_template( array $inner_block, \WP_Query $query, string $collection_type ): string {
if ( ! $query->have_posts() ) {
return $this->render_no_results_message();
}
$posts = $query->get_posts();
$total_count = count( $posts );
if ( 0 === $total_count ) {
return $this->render_no_results_message();
}
$products = array_filter(
array_map(
function ( $post ) {
return $post instanceof \WP_Post ? wc_get_product( $post->ID ) : null;
},
$posts
)
);
return $this->render_product_grid( $products, $inner_block, $collection_type );
}