WooCommerce Code Reference

WC_REST_Fulfillments_V4_Controller extends WC_REST_V4_Controller
in package

WooCommerce REST API Version 4 Fulfillments Controller

Tags
extends

WC_REST_V4_Controller

version
4.0.0

Table of Contents

$namespace  : string
Endpoint namespace.
$order_fulfillments_controller  : OrderFulfillmentsRestController
Order fulfillments controller instance.
$rest_base  : string
Route base.
__construct()  : mixed
Constructor.
check_permission_for_fulfillments()  : bool|WP_Error
Permission check for REST API endpoints, given the request method.
create_fulfillment()  : WP_REST_Response
Create a fulfillment for a specific order.
delete_fulfillment()  : WP_REST_Response
Delete a specific fulfillment for a specific order.
get_fulfillment()  : WP_REST_Response
Get a specific fulfillment for a specific order.
get_fulfillments()  : WP_REST_Response
Get a list of fulfillments for a specific order.
prepare_response_for_collection()  : array<string|int, mixed>
Prepare a response for inserting into a collection.
register_routes()  : mixed
Register the routes for fulfillments.
update_fulfillment()  : WP_REST_Response
Update a specific fulfillment for a specific order.
check_permissions()  : bool|WP_Error
Check permissions for a given request.
get_api_version()  : string
Get the default REST API version.
get_authentication_error_by_method()  : array<string|int, mixed>|null
Returns an authentication error message for a given HTTP verb.
get_base_schema()  : array<string|int, mixed>
Get the base schema for the API.
get_args_for_create_fulfillment()  : array<string|int, mixed>
Get the arguments for the create fulfillment endpoint.
get_args_for_delete_fulfillment()  : array<string|int, mixed>
Get the arguments for the delete fulfillment endpoint.
get_args_for_get_fulfillment()  : array<string|int, mixed>
Get the arguments for the get fulfillment endpoint.
get_args_for_get_fulfillments()  : array<string|int, mixed>
Get the arguments for the get order fulfillments endpoint.
get_args_for_update_fulfillment()  : array<string|int, mixed>
Get the arguments for the update fulfillment endpoint.
get_read_schema_for_fulfillment()  : array<string|int, mixed>
Get the base schema for the fulfillment with a read context.
get_schema_for_create_fulfillment()  : array<string|int, mixed>
Get the schema for the create fulfillment endpoint.
get_schema_for_delete_fulfillment()  : array<string|int, mixed>
Get the schema for the delete fulfillment endpoint.
get_schema_for_get_fulfillment()  : array<string|int, mixed>
Get the schema for the get fulfillment endpoint.
get_schema_for_get_fulfillments()  : array<string|int, mixed>
Get the schema for the get order fulfillments endpoint.
get_schema_for_meta_data()  : array<string|int, mixed>
Get the schema for the meta data.
get_schema_for_update_fulfillment()  : array<string|int, mixed>
Get the schema for the update fulfillment endpoint.
get_write_args_for_fulfillment()  : array<string|int, mixed>
Get the base args for the fulfillment with a write context.
prepare_error_response()  : WP_REST_Response
Prepare an error response.

Properties

Methods

check_permission_for_fulfillments()

Permission check for REST API endpoints, given the request method.

public check_permission_for_fulfillments(WP_REST_Request $request) : bool|WP_Error

For all fulfillments methods that have an order_id, we need to be sure the user has permission to view the order. For all other methods, we check if the user is logged in as admin and has the required capability.

Parameters
$request : WP_REST_Request

The request for which the permission is checked.

Tags
throws
WP_Error

If the URL contains an order, but the order does not exist.

Return values
bool|WP_ErrorTrue if the current user has the capability, otherwise an "Unauthorized" error or False if no error is available for the request method.

prepare_response_for_collection()

Prepare a response for inserting into a collection.

public prepare_response_for_collection(WP_REST_Response $response) : array<string|int, mixed>
Parameters
$response : WP_REST_Response

Response object.

Return values
array<string|int, mixed>Response data.

check_permissions()

Check permissions for a given request.

protected check_permissions(WP_REST_Request $request[, string $permission = 'read' ]) : bool|WP_Error
Parameters
$request : WP_REST_Request

Full details about the request.

$permission : string = 'read'

The permission to check for.

Return values
bool|WP_Error

prepare_error_response()

Prepare an error response.

private prepare_error_response(string $code, string $message, array<string|int, mixed> $data) : WP_REST_Response
Parameters
$code : string

The error code.

$message : string

The error message.

$data : array<string|int, mixed>

Additional error data, including 'status' key for HTTP status code.

Return values
WP_REST_ResponseThe error response.