Automattic\WooCommerce\Blocks\BlockTypes
AbstractProductGrid::render_product()
Render a single products.
Method of the class: AbstractProductGrid{}
Hooks from the method
Return
String
. Rendered product output.
Usage
// protected - for code of main (parent) or child class $result = $this->render_product( $product );
- $product(\WC_Product) (required)
- Product object.
AbstractProductGrid::render_product() AbstractProductGrid::render product code WC 9.4.2
protected function render_product( $product ) { $data = (object) array( 'permalink' => esc_url( $product->get_permalink() ), 'image' => $this->get_image_html( $product ), 'title' => $this->get_title_html( $product ), 'rating' => $this->get_rating_html( $product ), 'price' => $this->get_price_html( $product ), 'badge' => $this->get_sale_badge_html( $product ), 'button' => $this->get_button_html( $product ), ); /** * Filters the HTML for products in the grid. * * @param string $html Product grid item HTML. * @param array $data Product data passed to the template. * @param \WC_Product $product Product object. * @return string Updated product grid item HTML. * * @since 2.2.0 */ return apply_filters( 'woocommerce_blocks_product_grid_item_html', "<li class=\"wc-block-grid__product\"> <a href=\"{$data->permalink}\" class=\"wc-block-grid__product-link\"> {$data->badge} {$data->image} {$data->title} </a> {$data->price} {$data->rating} {$data->button} </li>", $data, $product ); }