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

WC_REST_Product_Variations_V2_Controller::get_item_schema() public WC 1.0

Get the Variation's schema, conforming to JSON Schema.

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

Хуков нет.

Возвращает

Массив.

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

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

Код WC_REST_Product_Variations_V2_Controller::get_item_schema() WC 4.7.1

<?php
public function get_item_schema() {
	$weight_unit    = get_option( 'woocommerce_weight_unit' );
	$dimension_unit = get_option( 'woocommerce_dimension_unit' );
	$schema         = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => $this->post_type,
		'type'       => 'object',
		'properties' => array(
			'id'                    => array(
				'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'date_created'          => array(
				'description' => __( "The date the variation was created, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'date_modified'         => array(
				'description' => __( "The date the variation was last modified, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'description'           => array(
				'description' => __( 'Variation description.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'permalink'             => array(
				'description' => __( 'Variation URL.', 'woocommerce' ),
				'type'        => 'string',
				'format'      => 'uri',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'sku'                   => array(
				'description' => __( 'Unique identifier.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'price'                 => array(
				'description' => __( 'Current variation price.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'regular_price'         => array(
				'description' => __( 'Variation regular price.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'sale_price'            => array(
				'description' => __( 'Variation sale price.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'date_on_sale_from'     => array(
				'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'date_on_sale_from_gmt' => array(
				'description' => __( 'Start date of sale price, as GMT.', 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'date_on_sale_to'       => array(
				'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'date_on_sale_to_gmt'   => array(
				'description' => __( 'End date of sale price, as GMT.', 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'on_sale'               => array(
				'description' => __( 'Shows if the variation is on sale.', 'woocommerce' ),
				'type'        => 'boolean',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'visible'               => array(
				'description' => __( "Define if the variation is visible on the product's page.", 'woocommerce' ),
				'type'        => 'boolean',
				'default'     => true,
				'context'     => array( 'view', 'edit' ),
			),
			'purchasable'           => array(
				'description' => __( 'Shows if the variation can be bought.', 'woocommerce' ),
				'type'        => 'boolean',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'virtual'               => array(
				'description' => __( 'If the variation is virtual.', 'woocommerce' ),
				'type'        => 'boolean',
				'default'     => false,
				'context'     => array( 'view', 'edit' ),
			),
			'downloadable'          => array(
				'description' => __( 'If the variation is downloadable.', 'woocommerce' ),
				'type'        => 'boolean',
				'default'     => false,
				'context'     => array( 'view', 'edit' ),
			),
			'downloads'             => array(
				'description' => __( 'List of downloadable files.', 'woocommerce' ),
				'type'        => 'array',
				'context'     => array( 'view', 'edit' ),
				'items'       => array(
					'type'       => 'object',
					'properties' => array(
						'id'   => array(
							'description' => __( 'File ID.', 'woocommerce' ),
							'type'        => 'string',
							'context'     => array( 'view', 'edit' ),
						),
						'name' => array(
							'description' => __( 'File name.', 'woocommerce' ),
							'type'        => 'string',
							'context'     => array( 'view', 'edit' ),
						),
						'file' => array(
							'description' => __( 'File URL.', 'woocommerce' ),
							'type'        => 'string',
							'context'     => array( 'view', 'edit' ),
						),
					),
				),
			),
			'download_limit'        => array(
				'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ),
				'type'        => 'integer',
				'default'     => -1,
				'context'     => array( 'view', 'edit' ),
			),
			'download_expiry'       => array(
				'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ),
				'type'        => 'integer',
				'default'     => -1,
				'context'     => array( 'view', 'edit' ),
			),
			'tax_status'            => array(
				'description' => __( 'Tax status.', 'woocommerce' ),
				'type'        => 'string',
				'default'     => 'taxable',
				'enum'        => array( 'taxable', 'shipping', 'none' ),
				'context'     => array( 'view', 'edit' ),
			),
			'tax_class'             => array(
				'description' => __( 'Tax class.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'manage_stock'          => array(
				'description' => __( 'Stock management at variation level.', 'woocommerce' ),
				'type'        => 'mixed',
				'default'     => false,
				'context'     => array( 'view', 'edit' ),
			),
			'stock_quantity'        => array(
				'description' => __( 'Stock quantity.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
			),
			'in_stock'              => array(
				'description' => __( 'Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ),
				'type'        => 'boolean',
				'default'     => true,
				'context'     => array( 'view', 'edit' ),
			),
			'backorders'            => array(
				'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ),
				'type'        => 'string',
				'default'     => 'no',
				'enum'        => array( 'no', 'notify', 'yes' ),
				'context'     => array( 'view', 'edit' ),
			),
			'backorders_allowed'    => array(
				'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ),
				'type'        => 'boolean',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'backordered'           => array(
				'description' => __( 'Shows if the variation is on backordered.', 'woocommerce' ),
				'type'        => 'boolean',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'weight'                => array(
				/* translators: %s: weight unit */
				'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'dimensions'            => array(
				'description' => __( 'Variation dimensions.', 'woocommerce' ),
				'type'        => 'object',
				'context'     => array( 'view', 'edit' ),
				'properties'  => array(
					'length' => array(
						/* translators: %s: dimension unit */
						'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit' ),
					),
					'width'  => array(
						/* translators: %s: dimension unit */
						'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit' ),
					),
					'height' => array(
						/* translators: %s: dimension unit */
						'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit' ),
					),
				),
			),
			'shipping_class'        => array(
				'description' => __( 'Shipping class slug.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'shipping_class_id'     => array(
				'description' => __( 'Shipping class ID.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'image'                 => array(
				'description' => __( 'Variation image data.', 'woocommerce' ),
				'type'        => 'object',
				'context'     => array( 'view', 'edit' ),
				'properties'  => array(
					'id'                => array(
						'description' => __( 'Image ID.', 'woocommerce' ),
						'type'        => 'integer',
						'context'     => array( 'view', 'edit' ),
					),
					'date_created'      => array(
						'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
						'type'        => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'date_created_gmt'  => array(
						'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
						'type'        => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'date_modified'     => array(
						'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
						'type'        => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'date_modified_gmt' => array(
						'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
						'type'        => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'src'               => array(
						'description' => __( 'Image URL.', 'woocommerce' ),
						'type'        => 'string',
						'format'      => 'uri',
						'context'     => array( 'view', 'edit' ),
					),
					'name'              => array(
						'description' => __( 'Image name.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit' ),
					),
					'alt'               => array(
						'description' => __( 'Image alternative text.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit' ),
					),
					'position'          => array(
						'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ),
						'type'        => 'integer',
						'context'     => array( 'view', 'edit' ),
					),
				),
			),
			'attributes'            => array(
				'description' => __( 'List of attributes.', 'woocommerce' ),
				'type'        => 'array',
				'context'     => array( 'view', 'edit' ),
				'items'       => array(
					'type'       => 'object',
					'properties' => array(
						'id'     => array(
							'description' => __( 'Attribute ID.', 'woocommerce' ),
							'type'        => 'integer',
							'context'     => array( 'view', 'edit' ),
						),
						'name'   => array(
							'description' => __( 'Attribute name.', 'woocommerce' ),
							'type'        => 'string',
							'context'     => array( 'view', 'edit' ),
						),
						'option' => array(
							'description' => __( 'Selected attribute term name.', 'woocommerce' ),
							'type'        => 'string',
							'context'     => array( 'view', 'edit' ),
						),
					),
				),
			),
			'menu_order'            => array(
				'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
			),
			'meta_data'             => array(
				'description' => __( 'Meta data.', 'woocommerce' ),
				'type'        => 'array',
				'context'     => array( 'view', 'edit' ),
				'items'       => array(
					'type'       => 'object',
					'properties' => array(
						'id'    => array(
							'description' => __( 'Meta ID.', 'woocommerce' ),
							'type'        => 'integer',
							'context'     => array( 'view', 'edit' ),
							'readonly'    => true,
						),
						'key'   => array(
							'description' => __( 'Meta key.', 'woocommerce' ),
							'type'        => 'string',
							'context'     => array( 'view', 'edit' ),
						),
						'value' => array(
							'description' => __( 'Meta value.', 'woocommerce' ),
							'type'        => 'mixed',
							'context'     => array( 'view', 'edit' ),
						),
					),
				),
			),
		),
	);

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