Automattic\WooCommerce\Blocks\BlockTypes

AbstractProductGrid::render_product()protectedWC 1.0

Render a single products.

{} Это метод класса: AbstractProductGrid{}

Хуки из метода

Возвращает

Строку. Rendered product output.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->render_product( $product );
$product(\WC_Product) (обязательный)
Product object.

Код AbstractProductGrid::render_product() WC 6.7.0

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.
	 */
	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->image}
				{$data->title}
			</a>
			{$data->badge}
			{$data->price}
			{$data->rating}
			{$data->button}
		</li>",
		$data,
		$product
	);
}