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

OrderSchema::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: OrderSchema{}

No Hooks.

Returns

Array.

Usage

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

OrderSchema::get_item_schema_properties() code WC 10.4.3

public function get_item_schema_properties(): array {
	$schema = array(
		'id'                   => array(
			'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
			'type'        => 'integer',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'parent_id'            => array(
			'description' => __( 'Parent order ID.', 'woocommerce' ),
			'type'        => 'integer',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'number'               => array(
			'description' => __( 'Order number.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'order_key'            => array(
			'description' => __( 'Order key.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'created_via'          => array(
			'description' => __( 'Shows where the order was created.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'version'              => array(
			'description' => __( 'Version of WooCommerce which last updated the order.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'status'               => array(
			'description' => __( 'Order status.', 'woocommerce' ),
			'type'        => 'string',
			'default'     => OrderStatus::PENDING,
			'enum'        => array_map( OrderUtil::class . '::remove_status_prefix', array_merge( array( OrderStatus::AUTO_DRAFT ), array_keys( wc_get_order_statuses() ) ) ),
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'currency'             => array(
			'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce' ),
			'type'        => 'string',
			'default'     => get_woocommerce_currency(),
			'enum'        => array_keys( get_woocommerce_currencies() ),
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'currency_symbol'      => array(
			'description' => __( 'Currency symbol for the currency which can be used to format returned prices.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'date_created'         => array(
			'description' => __( "The date the order was created, in the site's timezone.", 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'date-time',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'date_created_gmt'     => array(
			'description' => __( 'The date the order was created, as GMT.', 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'date-time',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'date_modified'        => array(
			'description' => __( "The date the order was last modified, in the site's timezone.", 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'date-time',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'date_modified_gmt'    => array(
			'description' => __( 'The date the order was last modified, as GMT.', 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'date-time',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'discount_total'       => array(
			'description' => __( 'Total discount amount for the order.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'discount_tax'         => array(
			'description' => __( 'Total discount tax amount for the order.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'shipping_total'       => array(
			'description' => __( 'Total shipping amount for the order.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'shipping_tax'         => array(
			'description' => __( 'Total shipping tax amount for the order.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'cart_tax'             => array(
			'description' => __( 'Sum of line item taxes only.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'total'                => array(
			'description' => __( 'Grand total.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'total_tax'            => array(
			'description' => __( 'Sum of all taxes.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'refund_total'         => array(
			'description' => __( 'Total refund amount for the order.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'refund_tax'           => array(
			'description' => __( 'Total refund tax amount for the order.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'prices_include_tax'   => array(
			'description' => __( 'True the prices included tax during checkout.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'customer_id'          => array(
			'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce' ),
			'type'        => 'integer',
			'default'     => 0,
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'customer_ip_address'  => array(
			'description' => __( "Customer's IP address.", 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'customer_user_agent'  => array(
			'description' => __( 'User agent of the customer.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'customer_note'        => array(
			'description' => __( 'Note left by customer during checkout.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'billing'              => array(
			'description' => __( 'Billing address.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'properties'  => array(
				'first_name' => array(
					'description' => __( 'First name.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'last_name'  => array(
					'description' => __( 'Last name.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'company'    => array(
					'description' => __( 'Company name.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'address_1'  => array(
					'description' => __( 'Address line 1', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'address_2'  => array(
					'description' => __( 'Address line 2', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'city'       => array(
					'description' => __( 'City name.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'state'      => array(
					'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'postcode'   => array(
					'description' => __( 'Postal code.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'country'    => array(
					'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'email'      => array(
					'description' => __( 'Email address.', 'woocommerce' ),
					'type'        => array( 'string', 'null' ),
					'format'      => 'email',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'phone'      => array(
					'description' => __( 'Phone number.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
			),
		),
		'shipping'             => array(
			'description' => __( 'Shipping address.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'properties'  => array(
				'first_name' => array(
					'description' => __( 'First name.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'last_name'  => array(
					'description' => __( 'Last name.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'company'    => array(
					'description' => __( 'Company name.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'address_1'  => array(
					'description' => __( 'Address line 1', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'address_2'  => array(
					'description' => __( 'Address line 2', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'city'       => array(
					'description' => __( 'City name.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'state'      => array(
					'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'postcode'   => array(
					'description' => __( 'Postal code.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'country'    => array(
					'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
				'phone'      => array(
					'description' => __( 'Phone number.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				),
			),
		),
		'payment_method'       => array(
			'description' => __( 'Payment method ID.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'payment_method_title' => array(
			'description' => __( 'Payment method title.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'arg_options' => array(
				'sanitize_callback' => 'sanitize_text_field',
			),
		),
		'transaction_id'       => array(
			'description' => __( 'Unique transaction ID.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
		),
		'date_paid'            => array(
			'description' => __( "The date the order was paid, in the site's timezone.", 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'date-time',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'date_paid_gmt'        => array(
			'description' => __( 'The date the order was paid, as GMT.', 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'date-time',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'date_completed'       => array(
			'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'date-time',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'date_completed_gmt'   => array(
			'description' => __( 'The date the order was completed, as GMT.', 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'date-time',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'cart_hash'            => array(
			'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'meta_data'            => array(
			'description' => __( 'Meta data.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'items'       => array(
				'type'       => 'object',
				'properties' => array(
					'id'    => array(
						'description' => __( 'Meta ID.', 'woocommerce' ),
						'type'        => 'integer',
						'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
						'readonly'    => true,
					),
					'key'   => array(
						'description' => __( 'Meta key.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
					),
					'value' => array(
						'description' => __( 'Meta value.', 'woocommerce' ),
						'type'        => array( 'null', 'object', 'string', 'number', 'boolean', 'integer', 'array' ),
						'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
					),
				),
			),
		),
		'line_items'           => array(
			'description' => __( 'A list of line items (products) within this order.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'items'       => array(
				'type'       => 'object',
				'properties' => $this->order_item_schema->get_item_schema_properties(),
			),
		),
		'tax_lines'            => array(
			'description' => __( 'Tax lines data.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
			'items'       => array(
				'type'       => 'object',
				'properties' => $this->order_tax_schema->get_item_schema_properties(),
			),
		),
		'shipping_lines'       => array(
			'description' => __( 'Shipping lines data.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'items'       => array(
				'type'       => 'object',
				'properties' => $this->order_shipping_schema->get_item_schema_properties(),
			),
		),
		'fee_lines'            => array(
			'description' => __( 'Fee lines data.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'items'       => array(
				'type'       => 'object',
				'properties' => $this->order_fee_schema->get_item_schema_properties(),
			),
		),
		'coupon_lines'         => array(
			'description' => __( 'Coupons line data.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'items'       => array(
				'type'       => 'object',
				'properties' => $this->order_coupon_schema->get_item_schema_properties(),
			),
		),
		'payment_url'          => array(
			'description' => __( 'Order payment URL.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'is_editable'          => array(
			'description' => __( 'Whether an order can be edited.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'needs_payment'        => array(
			'description' => __( 'Whether an order needs payment, based on status and order total.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'needs_processing'     => array(
			'description' => __( 'Whether an order needs processing before it can be completed.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
		'fulfillment_status'   => array(
			'description' => __( 'The fulfillment status of the order.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
			'readonly'    => true,
		),
	);

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

	return $schema;
}