Automattic\WooCommerce\StoreApi\Schemas\V1

ProductCollectionDataSchema::get_item_response()publicWC 1.0

Format data.

Method of the class: ProductCollectionDataSchema{}

No Hooks.

Return

Array.

Usage

$ProductCollectionDataSchema = new ProductCollectionDataSchema();
$ProductCollectionDataSchema->get_item_response( $data );
$data(array) (required)
Collection data to format and return.

ProductCollectionDataSchema::get_item_response() code WC 8.7.0

public function get_item_response( $data ) {
	return [
		'price_range'         => ! is_null( $data['min_price'] ) && ! is_null( $data['max_price'] ) ? (object) $this->prepare_currency_response(
			[
				'min_price' => $this->prepare_money_response( $data['min_price'], wc_get_price_decimals() ),
				'max_price' => $this->prepare_money_response( $data['max_price'], wc_get_price_decimals() ),
			]
		) : null,
		'attribute_counts'    => $data['attribute_counts'],
		'rating_counts'       => $data['rating_counts'],
		'stock_status_counts' => $data['stock_status_counts'],
	];
}