Automattic\WooCommerce\Internal\Orders
OrderActionsRestController::validate_order_id
Validate the order ID that is part of the endpoint URL.
Метод класса: OrderActionsRestController{}
Хуков нет.
Возвращает
int|WP_Error.
Использование
// private - только в коде основоного (родительского) класса $result = $this->validate_order_id( $request );
- $request(WP_REST_Request) (обязательный)
- The incoming HTTP REST request.
Код OrderActionsRestController::validate_order_id() OrderActionsRestController::validate order id WC 10.9.4
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;
}