WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

Automattic\WooCommerce\Blocks\StoreApi\Schemas

ProductSchema::get_item_response() public WC 1.0

Convert a WooCommerce product into an object suitable for the response.

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

Хуков нет.

Возвращает

Массив.

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

$ProductSchema = new ProductSchema();
$ProductSchema->get_item_response( $product );
$product(\WC_Product) (обязательный)
Product instance.

Код ProductSchema::get_item_response() WC 4.7.1

<?php
public function get_item_response( $product ) {
	return [
		'id'                  => $product->get_id(),
		'name'                => $this->prepare_html_response( $product->get_title() ),
		'parent'              => $product->get_parent_id(),
		'type'                => $product->get_type(),
		'variation'           => $this->prepare_html_response( $product->is_type( 'variation' ) ? wc_get_formatted_variation( $product, true, true, false ) : '' ),
		'permalink'           => $product->get_permalink(),
		'sku'                 => $this->prepare_html_response( $product->get_sku() ),
		'short_description'   => $this->prepare_html_response( wc_format_content( $product->get_short_description() ) ),
		'description'         => $this->prepare_html_response( wc_format_content( $product->get_description() ) ),
		'on_sale'             => $product->is_on_sale(),
		'prices'              => (object) $this->prepare_product_price_response( $product ),
		'price_html'          => $product->get_price_html(),
		'average_rating'      => $product->get_average_rating(),
		'review_count'        => $product->get_review_count(),
		'images'              => $this->get_images( $product ),
		'categories'          => $this->get_term_list( $product, 'product_cat' ),
		'tags'                => $this->get_term_list( $product, 'product_tag' ),
		'attributes'          => $this->get_attributes( $product ),
		'variations'          => $this->get_variations( $product ),
		'has_options'         => $product->has_options(),
		'is_purchasable'      => $product->is_purchasable(),
		'is_in_stock'         => $product->is_in_stock(),
		'is_on_backorder'     => 'onbackorder' === $product->get_stock_status(),
		'low_stock_remaining' => $this->get_low_stock_remaining( $product ),
		'sold_individually'   => $product->is_sold_individually(),
		'quantity_limit'      => $this->get_product_quantity_limit( $product ),
		'add_to_cart'         => (object) $this->prepare_html_response(
			[
				'text'        => $product->add_to_cart_text(),
				'description' => $product->add_to_cart_description(),
				'url'         => $product->add_to_cart_url(),
			]
		),
	];
}