Automattic\WooCommerce\StoreApi\Schemas\V1

ProductAttributeSchema::get_item_response()publicWC 1.0

Convert an attribute object into an object suitable for the response.

Метод класса: ProductAttributeSchema{}

Хуков нет.

Возвращает

Массив.

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

$ProductAttributeSchema = new ProductAttributeSchema();
$ProductAttributeSchema->get_item_response( $attribute );
$attribute(объект) (обязательный)
Attribute object.

Код ProductAttributeSchema::get_item_response() WC 8.7.0

public function get_item_response( $attribute ) {
	return [
		'id'           => (int) $attribute->id,
		'name'         => $this->prepare_html_response( $attribute->name ),
		'taxonomy'     => $attribute->slug,
		'type'         => $attribute->type,
		'order'        => $attribute->order_by,
		'has_archives' => $attribute->has_archives,
		'count'        => (int) \wp_count_terms( $attribute->slug ),
	];
}