Filter
rest_rp_cart_item_schema
On this page
Filters the JSON schema of a cart item in the REST API.
Applied when the cart controller builds its item schema. Add or change properties to expose extra data in cart responses. The result is cached on the controller and extended with any additional registered fields.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$schema | array | The JSON schema definition for the cart item. |
Return value#
array. The schema.
Example#
function my_cart_item_schema( $schema ) {
$schema['properties']['my_note'] = array(
'description' => __( 'Custom note.', 'my-textdomain' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
);
return $schema;
}
add_filter( 'rest_rp_cart_item_schema', 'my_cart_item_schema' );
Source#
Applied in:
includes/rest-api/Controllers/Version1/class-rp-rest-cart-v1-controller.php(line 162), inRP_REST_Cart_V1_Controller::get_item_schema()
See also#
Was this page helpful?
