Automattic\WooCommerce\StoreApi\Routes\V1

CartAddItem::get_args()publicWC 1.0

Get method arguments for this REST route.

Method of the class: CartAddItem{}

No Hooks.

Return

Array. An array of endpoints.

Usage

$CartAddItem = new CartAddItem();
$CartAddItem->get_args();

CartAddItem::get_args() code WC 8.7.0

public function get_args() {
	return [
		[
			'methods'             => \WP_REST_Server::CREATABLE,
			'callback'            => [ $this, 'get_response' ],
			'permission_callback' => '__return_true',
			'args'                => [
				'id'        => [
					'description'       => __( 'The cart item product or variation ID.', 'woocommerce' ),
					'type'              => 'integer',
					'context'           => [ 'view', 'edit' ],
					'sanitize_callback' => 'absint',
				],
				'quantity'  => [
					'description' => __( 'Quantity of this item to add to the cart.', 'woocommerce' ),
					'type'        => 'integer',
					'context'     => [ 'view', 'edit' ],
					'arg_options' => [
						'sanitize_callback' => 'wc_stock_amount',
					],
				],
				'variation' => [
					'description' => __( 'Chosen attributes (for variations).', 'woocommerce' ),
					'type'        => 'array',
					'context'     => [ 'view', 'edit' ],
					'items'       => [
						'type'       => 'object',
						'properties' => [
							'attribute' => [
								'description' => __( 'Variation attribute name.', 'woocommerce' ),
								'type'        => 'string',
								'context'     => [ 'view', 'edit' ],
							],
							'value'     => [
								'description' => __( 'Variation attribute value.', 'woocommerce' ),
								'type'        => 'string',
								'context'     => [ 'view', 'edit' ],
							],
						],
					],
				],
			],
		],
		'schema'      => [ $this->schema, 'get_public_item_schema' ],
		'allow_batch' => [ 'v1' => true ],
	];
}