WC_REST_Fulfillments_V4_Controller::update_fulfillmentpublicWC 1.0

Update a specific fulfillment 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->update_fulfillment( $request ): WP_REST_Response;
$request(WP_REST_Request) (required)
Full details about the request.

WC_REST_Fulfillments_V4_Controller::update_fulfillment() code WC 10.3.6

public function update_fulfillment( WP_REST_Request $request ): WP_REST_Response {
	$fulfillment_id = (int) $request->get_param( 'fulfillment_id' );
	$fulfillment    = new Fulfillment( $fulfillment_id );

	if ( ! $fulfillment->get_id() ) {
		return $this->prepare_error_response(
			'woocommerce_rest_fulfillment_invalid_id',
			__( 'Invalid fulfillment ID.', 'woocommerce' ),
			array( 'status' => esc_attr( WP_Http::NOT_FOUND ) )
		);
	}

	if ( $fulfillment->get_entity_type() !== \WC_Order::class ) {
		return $this->prepare_error_response(
			'woocommerce_rest_invalid_entity_type',
			__( 'The entity type must be "order".', 'woocommerce' ),
			array( 'status' => esc_attr( WP_Http::BAD_REQUEST ) )
		);
	}

	$order_id = (int) $fulfillment->get_entity_id();
	$request->set_param( 'order_id', $order_id );
	return $this->order_fulfillments_controller->update_fulfillment( $request );
}