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

Automattic\WooCommerce\Blocks\StoreApi\Schemas

ProductReviewSchema::get_item_response() public WC 1.0

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

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

Хуков нет.

Возвращает

Массив.

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

$ProductReviewSchema = new ProductReviewSchema();
$ProductReviewSchema->get_item_response( \WP_Comment $review );
$review(\WP_Comment) (обязательный)
Product review object.

Код ProductReviewSchema::get_item_response() WC 4.7.1

<?php
public function get_item_response( \WP_Comment $review ) {
	$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
	$rating  = get_comment_meta( $review->comment_ID, 'rating', true ) === '' ? null : (int) get_comment_meta( $review->comment_ID, 'rating', true );
	$data    = [
		'id'                     => (int) $review->comment_ID,
		'date_created'           => wc_rest_prepare_date_response( $review->comment_date ),
		'formatted_date_created' => get_comment_date( 'F j, Y', $review->comment_ID ),
		'date_created_gmt'       => wc_rest_prepare_date_response( $review->comment_date_gmt ),
		'product_id'             => (int) $review->comment_post_ID,
		'product_name'           => get_the_title( (int) $review->comment_post_ID ),
		'product_permalink'      => get_permalink( (int) $review->comment_post_ID ),
		'product_image'          => $this->image_attachment_schema->get_item_response( get_post_thumbnail_id( (int) $review->comment_post_ID ) ),
		'reviewer'               => $review->comment_author,
		'review'                 => $review->comment_content,
		'rating'                 => $rating,
		'verified'               => wc_review_is_from_verified_owner( $review->comment_ID ),
		'reviewer_avatar_urls'   => rest_get_avatar_urls( $review->comment_author_email ),
	];

	if ( 'view' === $context ) {
		$data['review'] = wpautop( $data['review'] );
	}

	return $data;
}