Automattic\WooCommerce\Internal\RestApi\Routes\V4\Orders\Schema

OrderItemSchema::get_item_schema_propertiespublicWC 1.0

Return all properties for the item schema.

Note that context determines under which context data should be visible. For example, edit would be the context used when getting records with the intent of editing them. embed context allows the data to be visible when the item is being embedded in another response.

Method of the class: OrderItemSchema{}

No Hooks.

Returns

Array.

Usage

$OrderItemSchema = new OrderItemSchema();
$OrderItemSchema->get_item_schema_properties(): array;

OrderItemSchema::get_item_schema_properties() code WC 10.4.3

public function get_item_schema_properties(): array {
	$schema = array(
		'id'           => array(
			'description' => __( 'Item ID.', 'woocommerce' ),
			'type'        => 'integer',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'name'         => array(
			'description' => __( 'Item name.', 'woocommerce' ),
			'type'        => array( 'string', 'null' ),
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'image'        => array(
			'description' => __( 'Line item image, if available.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'product_id'   => array(
			'description' => __( 'Product or variation ID.', 'woocommerce' ),
			'type'        => array( 'integer', 'null' ),
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'product_data' => array(
			'description' => __( 'Product data this item is linked to.', 'woocommerce' ),
			'type'        => array( 'object', 'null' ),
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'properties'  => $this->get_product_data_schema(),
		),
		'quantity'     => array(
			'description' => __( 'Quantity ordered.', 'woocommerce' ),
			'type'        => 'integer',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'price'        => array(
			'description' => __( 'Item price. Calculated as total / quantity.', 'woocommerce' ),
			'type'        => 'number',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'tax_class'    => array(
			'description' => __( 'Tax class of product.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'subtotal'     => array(
			'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'subtotal_tax' => array(
			'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'total'        => array(
			'description' => __( 'Line total (after discounts).', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'total_tax'    => array(
			'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'taxes'        => $this->get_taxes_schema(),
		'meta_data'    => $this->get_meta_data_schema(),
	);

	if ( $this->cogs_is_enabled() ) {
		$schema = $this->add_cogs_related_schema( $schema );
	}

	return $schema;
}