WC_REST_Fulfillments_V4_Controller
extends WC_REST_V4_Controller
in package
WooCommerce REST API Version 4 Fulfillments Controller
Tags
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
$namespace
Endpoint namespace.
protected
string
$namespace
= 'wc/v4'
$order_fulfillments_controller
Order fulfillments controller instance.
protected
OrderFulfillmentsRestController
$order_fulfillments_controller
$rest_base
Route base.
protected
string
$rest_base
= 'fulfillments'
Methods
__construct()
Constructor.
public
__construct() : mixed
Tags
Return values
mixed —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
Return values
bool|WP_Error — True if the current user has the capability, otherwise an "Unauthorized" error or False if no error is available for the request method.create_fulfillment()
Create a fulfillment for a specific order.
public
create_fulfillment(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Return values
WP_REST_Response —delete_fulfillment()
Delete a specific fulfillment for a specific order.
public
delete_fulfillment(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Return values
WP_REST_Response —get_fulfillment()
Get a specific fulfillment for a specific order.
public
get_fulfillment(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Return values
WP_REST_Response —get_fulfillments()
Get a list of fulfillments for a specific order.
public
get_fulfillments(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Return values
WP_REST_Response —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.register_routes()
Register the routes for fulfillments.
public
register_routes() : mixed
Tags
Return values
mixed —update_fulfillment()
Update a specific fulfillment for a specific order.
public
update_fulfillment(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
-
Full details about the request.
Return values
WP_REST_Response —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 —get_api_version()
Get the default REST API version.
protected
get_api_version() : string
Return values
string —get_authentication_error_by_method()
Returns an authentication error message for a given HTTP verb.
protected
get_authentication_error_by_method(string $method) : array<string|int, mixed>|null
Parameters
- $method : string
-
HTTP method.
Return values
array<string|int, mixed>|null — Error information on success, null otherwise.get_base_schema()
Get the base schema for the API.
protected
get_base_schema() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_args_for_create_fulfillment()
Get the arguments for the create fulfillment endpoint.
private
get_args_for_create_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_args_for_delete_fulfillment()
Get the arguments for the delete fulfillment endpoint.
private
get_args_for_delete_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_args_for_get_fulfillment()
Get the arguments for the get fulfillment endpoint.
private
get_args_for_get_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_args_for_get_fulfillments()
Get the arguments for the get order fulfillments endpoint.
private
get_args_for_get_fulfillments() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_args_for_update_fulfillment()
Get the arguments for the update fulfillment endpoint.
private
get_args_for_update_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_read_schema_for_fulfillment()
Get the base schema for the fulfillment with a read context.
private
get_read_schema_for_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_schema_for_create_fulfillment()
Get the schema for the create fulfillment endpoint.
private
get_schema_for_create_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_schema_for_delete_fulfillment()
Get the schema for the delete fulfillment endpoint.
private
get_schema_for_delete_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_schema_for_get_fulfillment()
Get the schema for the get fulfillment endpoint.
private
get_schema_for_get_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_schema_for_get_fulfillments()
Get the schema for the get order fulfillments endpoint.
private
get_schema_for_get_fulfillments() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_schema_for_meta_data()
Get the schema for the meta data.
private
get_schema_for_meta_data() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_schema_for_update_fulfillment()
Get the schema for the update fulfillment endpoint.
private
get_schema_for_update_fulfillment() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_write_args_for_fulfillment()
Get the base args for the fulfillment with a write context.
private
get_write_args_for_fulfillment([bool $is_create = false ]) : array<string|int, mixed>
Parameters
- $is_create : bool = false
-
Whether the args list is for a create request.
Return values
array<string|int, mixed> —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.
