Automattic\WooCommerce\StoreApi\Schemas\V1

ProductSchema::get_propertiespublicWC 1.0

Product schema properties.

Method of the class: ProductSchema{}

No Hooks.

Returns

Array.

Usage

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

ProductSchema::get_properties() code WC 10.7.0

public function get_properties() {
	return [
		'id'                    => [
			'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
			'type'        => 'integer',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'name'                  => [
			'description' => __( 'Product name.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit', 'embed' ],
		],
		'slug'                  => [
			'description' => __( 'Product slug.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit', 'embed' ],
		],
		'parent'                => [
			'description' => __( 'ID of the parent product, if applicable.', 'woocommerce' ),
			'type'        => 'integer',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'type'                  => [
			'description' => __( 'Product type.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'variation'             => [
			'description' => __( 'Product variation attributes, if applicable.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit', 'embed' ],
		],
		'permalink'             => [
			'description' => __( 'Product URL.', 'woocommerce' ),
			'type'        => 'string',
			'format'      => 'uri',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'short_description'     => [
			'description' => __( 'Product short description in HTML format.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit', 'embed' ],
		],
		'description'           => [
			'description' => __( 'Product full description in HTML format.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit', 'embed' ],
		],
		'on_sale'               => [
			'description' => __( 'Is the product on sale?', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'sku'                   => [
			'description' => __( 'Unique identifier.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit', 'embed' ],
		],
		'prices'                => [
			'description' => __( 'Price data provided using the smallest unit of the currency.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
			'properties'  => array_merge(
				$this->get_store_currency_properties(),
				[
					'price'         => [
						'description' => __( 'Current product price.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'regular_price' => [
						'description' => __( 'Regular product price.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'sale_price'    => [
						'description' => __( 'Sale product price, if applicable.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'price_range'   => [
						'description' => __( 'Price range, if applicable.', 'woocommerce' ),
						'type'        => [ 'object', 'null' ],
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
						'properties'  => [
							'min_amount' => [
								'description' => __( 'Price amount.', 'woocommerce' ),
								'type'        => 'string',
								'context'     => [ 'view', 'edit', 'embed' ],
								'readonly'    => true,
							],
							'max_amount' => [
								'description' => __( 'Price amount.', 'woocommerce' ),
								'type'        => 'string',
								'context'     => [ 'view', 'edit', 'embed' ],
								'readonly'    => true,
							],
						],
					],
				]
			),
		],
		'price_html'            => array(
			'description' => __( 'Price string formatted as HTML.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => array( 'view', 'edit', 'embed' ),
			'readonly'    => true,
		),
		'average_rating'        => [
			'description' => __( 'Reviews average rating.', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'review_count'          => [
			'description' => __( 'Amount of reviews that the product has.', 'woocommerce' ),
			'type'        => 'integer',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'images'                => [
			'description' => __( 'List of images.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit', 'embed' ],
			'items'       => [
				'type'       => 'object',
				'properties' => $this->image_attachment_schema->get_properties(),
			],
		],
		'categories'            => [
			'description' => __( 'List of categories, if applicable.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit', 'embed' ],
			'items'       => [
				'type'       => 'object',
				'properties' => [
					'id'   => [
						'description' => __( 'Category ID', 'woocommerce' ),
						'type'        => 'number',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'name' => [
						'description' => __( 'Category name', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'slug' => [
						'description' => __( 'Category slug', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'link' => [
						'description' => __( 'Category link', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
				],
			],
		],
		'tags'                  => [
			'description' => __( 'List of tags, if applicable.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit', 'embed' ],
			'items'       => [
				'type'       => 'object',
				'properties' => [
					'id'   => [
						'description' => __( 'Tag ID', 'woocommerce' ),
						'type'        => 'number',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'name' => [
						'description' => __( 'Tag name', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'slug' => [
						'description' => __( 'Tag slug', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'link' => [
						'description' => __( 'Tag link.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
				],
			],
		],
		'brands'                => [
			'description' => __( 'List of brands, if applicable.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit', 'embed' ],
			'items'       => [
				'type'       => 'object',
				'properties' => [
					'id'   => [
						'description' => __( 'Brand ID', 'woocommerce' ),
						'type'        => 'number',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'name' => [
						'description' => __( 'Brand name', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'slug' => [
						'description' => __( 'Brand slug', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'link' => [
						'description' => __( 'Brand link', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
				],
			],
		],
		'attributes'            => [
			'description' => __( 'List of attributes (taxonomy terms) assigned to the product. For variable products, these are mapped to variations (see the `variations` field).', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit', 'embed' ],
			'items'       => [
				'type'       => 'object',
				'properties' => [
					'id'             => [
						'description' => __( 'The attribute ID, or 0 if the attribute is not taxonomy based.', 'woocommerce' ),
						'type'        => 'integer',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'name'           => [
						'description' => __( 'The attribute name.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'taxonomy'       => [
						'description' => __( 'The attribute taxonomy, or null if the attribute is not taxonomy based.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'has_variations' => [
						'description' => __( 'True if this attribute is used by product variations.', 'woocommerce' ),
						'type'        => 'boolean',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'terms'          => [
						'description' => __( 'List of assigned attribute terms.', 'woocommerce' ),
						'type'        => 'array',
						'context'     => [ 'view', 'edit', 'embed' ],
						'items'       => [
							'type'       => 'object',
							'properties' => [
								'id'      => [
									'description' => __( 'The term ID, or 0 if the attribute is not a global attribute.', 'woocommerce' ),
									'type'        => 'integer',
									'context'     => [ 'view', 'edit', 'embed' ],
									'readonly'    => true,
								],
								'name'    => [
									'description' => __( 'The term name.', 'woocommerce' ),
									'type'        => 'string',
									'context'     => [ 'view', 'edit', 'embed' ],
									'readonly'    => true,
								],
								'slug'    => [
									'description' => __( 'The term slug.', 'woocommerce' ),
									'type'        => 'string',
									'context'     => [ 'view', 'edit', 'embed' ],
									'readonly'    => true,
								],
								'default' => [
									'description' => __( 'If this is a default attribute', 'woocommerce' ),
									'type'        => 'boolean',
									'context'     => [ 'view', 'edit', 'embed' ],
									'readonly'    => true,
								],
							],
						],
					],
				],
			],
		],
		'variations'            => [
			'description' => __( 'List of variation IDs, if applicable.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit', 'embed' ],
			'items'       => [
				'type'       => 'object',
				'properties' => [
					'id'         => [
						'description' => __( 'The attribute ID, or 0 if the attribute is not taxonomy based.', 'woocommerce' ),
						'type'        => 'integer',
						'context'     => [ 'view', 'edit', 'embed' ],
						'readonly'    => true,
					],
					'attributes' => [
						'description' => __( 'List of variation attributes.', 'woocommerce' ),
						'type'        => 'array',
						'context'     => [ 'view', 'edit', 'embed' ],
						'items'       => [
							'type'       => 'object',
							'properties' => [
								'name'  => [
									'description' => __( 'The attribute name.', 'woocommerce' ),
									'type'        => 'string',
									'context'     => [ 'view', 'edit', 'embed' ],
									'readonly'    => true,
								],
								'value' => [
									'description' => __( 'The assigned attribute.', 'woocommerce' ),
									'type'        => 'string',
									'context'     => [ 'view', 'edit', 'embed' ],
									'readonly'    => true,
								],
							],
						],
					],
				],
			],
		],
		'grouped_products'      => [
			'description' => __( 'List of grouped product IDs, if applicable.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit', 'embed' ],
			'items'       => [
				'description' => __( 'List of grouped product ids.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => [ 'view', 'edit', 'embed' ],
				'readonly'    => true,
			],
		],
		'has_options'           => [
			'description' => __( 'Does the product have additional options before it can be added to the cart?', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'is_purchasable'        => [
			'description' => __( 'Is the product purchasable?', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'is_in_stock'           => [
			'description' => __( 'Is the product in stock?', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'is_on_backorder'       => [
			'description' => __( 'Is the product stock backordered? This will also return false if backorder notifications are turned off.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'stock_availability'    => [
			'description' => __( 'Information about the product\'s availability.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
			'properties'  => [
				'text'  => [
					'description' => __( 'Stock availability text.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
				],
				'class' => [
					'description' => __( 'Stock availability class.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
				],
			],
		],
		'low_stock_remaining'   => [
			'description' => __( 'Quantity left in stock if stock is low, or null if not applicable.', 'woocommerce' ),
			'type'        => [ 'number', 'null' ],
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'sold_individually'     => [
			'description' => __( 'If true, only one item of this product is allowed for purchase in a single order.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		'weight'                => [
			'description' => sprintf(
				/* translators: %s: weight unit */
				__( 'Product weight (%s).', 'woocommerce' ),
				get_option( 'woocommerce_weight_unit' )
			),
			'type'        => 'string',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'dimensions'            => [
			'description' => __( 'Product dimensions.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'properties'  => [
				'length' => [
					'description' => sprintf(
						/* translators: %s: dimension unit */
						__( 'Product length (%s).', 'woocommerce' ),
						get_option( 'woocommerce_dimension_unit' )
					),
					'type'        => 'string',
					'context'     => [ 'view', 'edit' ],
					'readonly'    => true,
				],
				'width'  => [
					'description' => sprintf(
						/* translators: %s: dimension unit */
						__( 'Product width (%s).', 'woocommerce' ),
						get_option( 'woocommerce_dimension_unit' )
					),
					'type'        => 'string',
					'context'     => [ 'view', 'edit' ],
					'readonly'    => true,
				],
				'height' => [
					'description' => sprintf(
						/* translators: %s: dimension unit */
						__( 'Product height (%s).', 'woocommerce' ),
						get_option( 'woocommerce_dimension_unit' )
					),
					'type'        => 'string',
					'context'     => [ 'view', 'edit' ],
					'readonly'    => true,
				],
			],
		],
		'formatted_weight'      => [
			'description' => __( 'Product weight formatted for display (e.g. "2.5 kg").', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'formatted_dimensions'  => [
			'description' => __( 'Product dimensions formatted for display (e.g. "10 × 5 × 3 cm").', 'woocommerce' ),
			'type'        => 'string',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'add_to_cart'           => [
			'description' => __( 'Add to cart button parameters.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
			'properties'  => [
				'text'        => [
					'description' => __( 'Button text.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
				],
				'description' => [
					'description' => __( 'Button description.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
				],
				'url'         => [
					'description' => __( 'Add to cart URL.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
				],
				'minimum'     => [
					'description' => __( 'The minimum quantity that can be added to the cart.', 'woocommerce' ),
					'type'        => 'number',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
				],
				'maximum'     => [
					'description' => __( 'The maximum quantity that can be added to the cart.', 'woocommerce' ),
					'type'        => 'number',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
				],
				'multiple_of' => [
					'description' => __( 'The amount that quantities increment by. Quantity must be an multiple of this value.', 'woocommerce' ),
					'type'        => 'number',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
					'default'     => 1,
				],
				'single_text' => [
					'description' => __( 'Button text in the single product page.', 'woocommerce' ),
					'type'        => 'string',
					'context'     => [ 'view', 'edit', 'embed' ],
					'readonly'    => true,
				],
			],
		],
		'is_password_protected' => [
			'description' => __( 'Whether the product requires a password to access its content.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit', 'embed' ],
			'readonly'    => true,
		],
		self::EXTENDING_KEY     => $this->get_extended_schema( self::IDENTIFIER ),
	];
}