WC_REST_Fulfillments_V4_Controller::get_fulfillments
Get a list of fulfillments for a specific order.
Method of the class: WC_REST_Fulfillments_V4_Controller{}
No Hooks.
Returns
WP_REST_Response.
Usage
$WC_REST_Fulfillments_V4_Controller = new WC_REST_Fulfillments_V4_Controller(); $WC_REST_Fulfillments_V4_Controller->get_fulfillments( $request ): WP_REST_Response;
- $request(WP_REST_Request) (required)
- Full details about the request.
WC_REST_Fulfillments_V4_Controller::get_fulfillments() WC REST Fulfillments V4 Controller::get fulfillments code WC 10.3.6
public function get_fulfillments( WP_REST_Request $request ): WP_REST_Response {
$order_id = (int) $request->get_param( 'order_id' );
// Validate the order ID.
if ( ! $order_id ) {
return $this->prepare_error_response(
'woocommerce_rest_order_id_required',
__( 'The order ID is required.', 'woocommerce' ),
array( 'status' => esc_attr( WP_Http::BAD_REQUEST ) )
);
}
$order = wc_get_order( $order_id );
if ( ! $order ) {
return $this->prepare_error_response(
'woocommerce_rest_order_invalid_id',
__( 'Invalid order ID.', 'woocommerce' ),
array( 'status' => esc_attr( WP_Http::NOT_FOUND ) )
);
}
$request->set_param( 'order_id', $order_id );
return $this->order_fulfillments_controller->get_fulfillments( $request );
}