Automattic\WooCommerce\StoreApi\Schemas\V1

OrderItemSchema::get_properties │ public │ WC 11.2.0

Item schema properties.

The inherited item_data describes the cart's display data. Order items carry stored meta rows, which have different properties.

Method of the class: OrderItemSchema{}

No Hooks.

Returns

array.

Usage

$OrderItemSchema = new OrderItemSchema();
$OrderItemSchema->get_properties();

Changelog

Since 11.2.0 Introduced.

OrderItemSchema::get_properties() code WC 11.2.1

public function get_properties() {
	$properties = parent::get_properties();

	$properties['item_data'] = [
		'description' => __( 'Metadata related to the item.', 'woocommerce' ),
		'type'        => 'array',
		'context'     => [ 'view', 'edit' ],
		'readonly'    => true,
		'items'       => [
			'type'       => 'object',
			'properties' => [
				'id'            => [
					'description' => __( 'Order item metadata ID. Null for an entry that no displayed metadata row backs, such as one an extension added.', 'woocommerce' ),
					'type'        => [ 'integer', 'null' ],
					'context'     => [ 'view', 'edit' ],
					'readonly'    => true,
				],
				'key'           => [
					'description' => __( 'Metadata key.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit' ],
					'readonly'    => true,
				],
				'value'         => [
					'description' => __( 'Metadata value.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit' ],
					'readonly'    => true,
				],
				'display_key'   => [
					'description' => __( 'Metadata key, formatted for display.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit' ],
					'readonly'    => true,
				],
				'display_value' => [
					'description' => __( 'Metadata value, formatted for display.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit' ],
					'readonly'    => true,
				],
			],
		],
	];

	return $properties;
}