Automattic\WooCommerce\Internal\Orders
OrderActionsRestController::validate_order_id
Validate the order ID that is part of the endpoint URL.
Method of the class: OrderActionsRestController{}
No Hooks.
Returns
Int|WP_Error
.
Usage
// private - for code of main (parent) class only $result = $this->validate_order_id( $request );
- $request(WP_REST_Request) (required)
- The incoming HTTP REST request.
OrderActionsRestController::validate_order_id() OrderActionsRestController::validate order id code WC 9.8.5
private function validate_order_id( WP_REST_Request $request ) { $order_id = $request->get_param( 'id' ); $order = wc_get_order( $order_id ); if ( ! $order ) { return new WP_Error( 'woocommerce_rest_not_found', __( 'Order not found', 'woocommerce' ), array( 'status' => 404 ) ); } return $order_id; }