Automattic\WooCommerce\StoreApi\Schemas\V1
CartExtensionsSchema::get_item_response()
Handle the request and return a valid response for this endpoint.
Method of the class: CartExtensionsSchema{}
No Hooks.
Return
Array
.
Usage
$CartExtensionsSchema = new CartExtensionsSchema(); $CartExtensionsSchema->get_item_response( $request );
- $request(\WP_REST_Request)
- Request containing data for the extension callback.
Default: null
CartExtensionsSchema::get_item_response() CartExtensionsSchema::get item response code WC 9.3.3
public function get_item_response( $request = null ) { try { $callback = $this->extend->get_update_callback( $request['namespace'] ); } catch ( \Exception $e ) { throw new RouteException( 'woocommerce_rest_cart_extensions_error', esc_html( $e->getMessage() ), 400 ); } // Run the callback. Exceptions are not caught here. $callback( $request['data'] ); try { // We recalculate the cart if we had something to run. $controller = new CartController(); $cart = $controller->calculate_totals(); $response = $this->cart_schema->get_item_response( $cart ); return rest_ensure_response( $response ); } catch ( \Exception $e ) { throw new RouteException( 'woocommerce_rest_cart_extensions_error', esc_html( $e->getMessage() ), 400 ); } }