WC_REST_Data_Countries_Controller::get_item_schema()publicWC 3.5.0

Get the location schema, conforming to JSON Schema.

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

Хуков нет.

Возвращает

Массив.

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

$WC_REST_Data_Countries_Controller = new WC_REST_Data_Countries_Controller();
$WC_REST_Data_Countries_Controller->get_item_schema();

Список изменений

С версии 3.5.0 Введена.

Код WC_REST_Data_Countries_Controller::get_item_schema() WC 8.7.0

public function get_item_schema() {
	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'data_countries',
		'type'       => 'object',
		'properties' => array(
			'code'   => array(
				'type'        => 'string',
				'description' => __( 'ISO3166 alpha-2 country code.', 'woocommerce' ),
				'context'     => array( 'view' ),
				'readonly'    => true,
			),
			'name'   => array(
				'type'        => 'string',
				'description' => __( 'Full name of country.', 'woocommerce' ),
				'context'     => array( 'view' ),
				'readonly'    => true,
			),
			'states' => array(
				'type'        => 'array',
				'description' => __( 'List of states in this country.', 'woocommerce' ),
				'context'     => array( 'view' ),
				'readonly'    => true,
				'items'       => array(
					'type'       => 'object',
					'context'    => array( 'view' ),
					'readonly'   => true,
					'properties' => array(
						'code' => array(
							'type'        => 'string',
							'description' => __( 'State code.', 'woocommerce' ),
							'context'     => array( 'view' ),
							'readonly'    => true,
						),
						'name' => array(
							'type'        => 'string',
							'description' => __( 'Full name of state.', 'woocommerce' ),
							'context'     => array( 'view' ),
							'readonly'    => true,
						),
					),
				),
			),
		),
	);

	return $this->add_additional_fields_schema( $schema );
}