sponse */ protected function add_response_headers( \WP_REST_Response $response ) { $nonce = wp_create_nonce( 'wc_store_api' ); $response->header( 'Nonce', $nonce ); $response->header( 'Nonce-Timestamp', time() ); $response->header( 'User-ID', get_current_user_id() ); $response->header( 'Cart-Token', $this->get_cart_token() ); // The following headers are deprecated and should be removed in a future version. $response->header( 'X-WC-Store-API-Nonce', $nonce ); return $response; } /** * Load the cart session before handling responses. * * @param \WP_REST_Request $request Request object. */ protected function load_cart_session( \WP_REST_Request $request ) { $cart_token = $request->get_header( 'Cart-Token' ); if ( $cart_token && JsonWebToken::validate( $cart_token, $this->get_cart_token_secret() ) ) { // Overrides the core session class. add_filter( 'woocommerce_session_handler', function () { return SessionHandler::class; } ); } $this->cart_controller->load_cart(); } /** * Generates a cart token for the response headers. * * Current namespace is used as the token Issuer. * * * * @return string */ protected function get_cart_token() { return JsonWebToken::create( [ 'user_id' => wc()->session->get_customer_id(), 'exp' => $this->get_cart_token_expiration(), 'iss' => $this->namespace, ], $this->get_cart_token_secret() ); } /** * Gets the secret for the cart token using wp_salt. * * @return string */ protected function get_cart_token_secret() { return '@' . wp_salt(); } /** * Gets the expiration of the cart token. Defaults to 48h. * * @return int */ protected function get_cart_token_expiration() { /** * Filters the session expiration. * * @since 8.7.0 * * @param int $expiration Expiration in seconds. */ return time() + intval( apply_filters( 'wc_session_expiration', DAY_IN_SECONDS * 2 ) ); } /** * Checks if a nonce is required for the route. * * @param \WP_REST_Request $request Request. * * @return bool */ protected function requires_nonce( \WP_REST_Request $request ) { return $this->is_update_request( $request ); } /** * Triggered after an update to cart data. Re-calculates totals and updates draft orders (if they already exist) to * keep all data in sync. * * @param \WP_REST_Request $request Request object. */ protected function cart_updated( \WP_REST_Request $request ) { $draft_order = $this->get_draft_order(); if ( $draft_order ) { // This does not trigger a recalculation of the cart--endpoints should have already done so before returning // the cart response. $this->order_controller->update_order_from_cart( $draft_order, false ); wc_do_deprecated_action( 'woocommerce_blocks_cart_update_order_from_request', array( $draft_order, $request, ), '7.2.0', 'woocommerce_store_api_cart_update_order_from_request', 'This action was deprecated in WooCommerce Blocks version 7.2.0. Please use woocommerce_store_api_cart_update_order_from_request instead.' ); /** * Fires when the order is synced with cart data from a cart route. * * @since 7.2.0 * * @param \WC_Order $draft_order Order object. * @param \WC_Customer $customer Customer object. * @param \WP_REST_Request $request Full details about the request. */ do_action( 'woocommerce_store_api_cart_update_order_from_request', $draft_order, $request ); } } /** * For non-GET endpoints, require and validate a nonce to prevent CSRF attacks. * * Nonces will mismatch if the logged in session cookie is different! If using a client to test, set this cookie * to match the logged in cookie in your browser. * * @param \WP_REST_Request $request Request object. * * @return \WP_Error|boolean */ protected function check_nonce( \WP_REST_Request $request ) { $nonce = null; if ( $request->get_header( 'Nonce' ) ) { $nonce = $request->get_header( 'Nonce' ); } elseif ( $request->get_header( 'X-WC-Store-API-Nonce' ) ) { $nonce = $request->get_header( 'X-WC-Store-API-Nonce' ); // @todo Remove handling and sending of deprecated X-WC-Store-API-Nonce Header (Blocks 7.5.0) wc_deprecated_argument( 'X-WC-Store-API-Nonce', '7.2.0', 'Use the "Nonce" Header instead. This header will be removed after Blocks release 7.5' ); rest_handle_deprecated_argument( 'X-WC-Store-API-Nonce', 'Use the "Nonce" Header instead. This header will be removed after Blocks release 7.5', '7.2.0' ); } /** * Filters the Store API nonce check. * * This can be used to disable the nonce check when testing API endpoints via a REST API client. * * @since 4.5.0 * * @param boolean $disable_nonce_check If true, nonce checks will be disabled. * * @return boolean */ if ( apply_filters( 'woocommerce_store_api_disable_nonce_check', false ) ) { return true; } if ( null === $nonce ) { return $this->get_route_error_response( 'woocommerce_rest_missing_nonce', __( 'Missing the Nonce header. This endpoint requires a valid nonce.', 'woocommerce' ), 401 ); } if ( ! wp_verify_nonce( $nonce, 'wc_store_api' ) ) { return $this->get_route_error_response( 'woocommerce_rest_invalid_nonce', __( 'Nonce is invalid.', 'woocommerce' ), 403 ); } return true; } /** * Get route response when something went wrong. * * @param string $error_code String based error code. * @param string $error_message User facing error message. * @param int $http_status_code HTTP status. Defaults to 500. * @param array $additional_data Extra data (key value pairs) to expose in the error response. * * @return \WP_Error WP Error object. */ protected function get_route_error_response( $error_code, $error_message, $http_status_code = 500, $additional_data = [] ) { $additional_data['status'] = $http_status_code; // If there was a conflict, return the cart so the client can resolve it. if ( 409 === $http_status_code ) { $cart = $this->cart_controller->get_cart_instance(); $additional_data['cart'] = $this->cart_schema->get_item_response( $cart ); } return new \WP_Error( $error_code, $error_message, $additional_data ); } }
Warning: Class "Automattic\WooCommerce\StoreApi\Routes\V1\AbstractCartRoute" not found in /htdocs/wp-content/plugins/woocommerce/src/StoreApi/deprecated.php on line 73
sponse */ protected function add_response_headers( \WP_REST_Response $response ) { $nonce = wp_create_nonce( 'wc_store_api' ); $response->header( 'Nonce', $nonce ); $response->header( 'Nonce-Timestamp', time() ); $response->header( 'User-ID', get_current_user_id() ); $response->header( 'Cart-Token', $this->get_cart_token() ); // The following headers are deprecated and should be removed in a future version. $response->header( 'X-WC-Store-API-Nonce', $nonce ); return $response; } /** * Load the cart session before handling responses. * * @param \WP_REST_Request $request Request object. */ protected function load_cart_session( \WP_REST_Request $request ) { $cart_token = $request->get_header( 'Cart-Token' ); if ( $cart_token && JsonWebToken::validate( $cart_token, $this->get_cart_token_secret() ) ) { // Overrides the core session class. add_filter( 'woocommerce_session_handler', function () { return SessionHandler::class; } ); } $this->cart_controller->load_cart(); } /** * Generates a cart token for the response headers. * * Current namespace is used as the token Issuer. * * * * @return string */ protected function get_cart_token() { return JsonWebToken::create( [ 'user_id' => wc()->session->get_customer_id(), 'exp' => $this->get_cart_token_expiration(), 'iss' => $this->namespace, ], $this->get_cart_token_secret() ); } /** * Gets the secret for the cart token using wp_salt. * * @return string */ protected function get_cart_token_secret() { return '@' . wp_salt(); } /** * Gets the expiration of the cart token. Defaults to 48h. * * @return int */ protected function get_cart_token_expiration() { /** * Filters the session expiration. * * @since 8.7.0 * * @param int $expiration Expiration in seconds. */ return time() + intval( apply_filters( 'wc_session_expiration', DAY_IN_SECONDS * 2 ) ); } /** * Checks if a nonce is required for the route. * * @param \WP_REST_Request $request Request. * * @return bool */ protected function requires_nonce( \WP_REST_Request $request ) { return $this->is_update_request( $request ); } /** * Triggered after an update to cart data. Re-calculates totals and updates draft orders (if they already exist) to * keep all data in sync. * * @param \WP_REST_Request $request Request object. */ protected function cart_updated( \WP_REST_Request $request ) { $draft_order = $this->get_draft_order(); if ( $draft_order ) { // This does not trigger a recalculation of the cart--endpoints should have already done so before returning // the cart response. $this->order_controller->update_order_from_cart( $draft_order, false ); wc_do_deprecated_action( 'woocommerce_blocks_cart_update_order_from_request', array( $draft_order, $request, ), '7.2.0', 'woocommerce_store_api_cart_update_order_from_request', 'This action was deprecated in WooCommerce Blocks version 7.2.0. Please use woocommerce_store_api_cart_update_order_from_request instead.' ); /** * Fires when the order is synced with cart data from a cart route. * * @since 7.2.0 * * @param \WC_Order $draft_order Order object. * @param \WC_Customer $customer Customer object. * @param \WP_REST_Request $request Full details about the request. */ do_action( 'woocommerce_store_api_cart_update_order_from_request', $draft_order, $request ); } } /** * For non-GET endpoints, require and validate a nonce to prevent CSRF attacks. * * Nonces will mismatch if the logged in session cookie is different! If using a client to test, set this cookie * to match the logged in cookie in your browser. * * @param \WP_REST_Request $request Request object. * * @return \WP_Error|boolean */ protected function check_nonce( \WP_REST_Request $request ) { $nonce = null; if ( $request->get_header( 'Nonce' ) ) { $nonce = $request->get_header( 'Nonce' ); } elseif ( $request->get_header( 'X-WC-Store-API-Nonce' ) ) { $nonce = $request->get_header( 'X-WC-Store-API-Nonce' ); // @todo Remove handling and sending of deprecated X-WC-Store-API-Nonce Header (Blocks 7.5.0) wc_deprecated_argument( 'X-WC-Store-API-Nonce', '7.2.0', 'Use the "Nonce" Header instead. This header will be removed after Blocks release 7.5' ); rest_handle_deprecated_argument( 'X-WC-Store-API-Nonce', 'Use the "Nonce" Header instead. This header will be removed after Blocks release 7.5', '7.2.0' ); } /** * Filters the Store API nonce check. * * This can be used to disable the nonce check when testing API endpoints via a REST API client. * * @since 4.5.0 * * @param boolean $disable_nonce_check If true, nonce checks will be disabled. * * @return boolean */ if ( apply_filters( 'woocommerce_store_api_disable_nonce_check', false ) ) { return true; } if ( null === $nonce ) { return $this->get_route_error_response( 'woocommerce_rest_missing_nonce', __( 'Missing the Nonce header. This endpoint requires a valid nonce.', 'woocommerce' ), 401 ); } if ( ! wp_verify_nonce( $nonce, 'wc_store_api' ) ) { return $this->get_route_error_response( 'woocommerce_rest_invalid_nonce', __( 'Nonce is invalid.', 'woocommerce' ), 403 ); } return true; } /** * Get route response when something went wrong. * * @param string $error_code String based error code. * @param string $error_message User facing error message. * @param int $http_status_code HTTP status. Defaults to 500. * @param array $additional_data Extra data (key value pairs) to expose in the error response. * * @return \WP_Error WP Error object. */ protected function get_route_error_response( $error_code, $error_message, $http_status_code = 500, $additional_data = [] ) { $additional_data['status'] = $http_status_code; // If there was a conflict, return the cart so the client can resolve it. if ( 409 === $http_status_code ) { $cart = $this->cart_controller->get_cart_instance(); $additional_data['cart'] = $this->cart_schema->get_item_response( $cart ); } return new \WP_Error( $error_code, $error_message, $additional_data ); } }
Warning: Class "Automattic\WooCommerce\StoreApi\Routes\V1\Cart" not found in /htdocs/wp-content/plugins/woocommerce/src/StoreApi/deprecated.php on line 73

Fatal error: Uncaught Error: Class "Automattic\WooCommerce\StoreApi\Routes\V1\AbstractCartRoute" not found in /htdocs/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1/Cart.php:7 Stack trace: #0 /htdocs/wp-content/plugins/jetpack/vendor/jetpack-autoloader/class-php-autoloader.php(90): require() #1 [internal function]: Automattic\Jetpack\Autoloader\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ13_5\al3_0_8\PHP_Autoloader::load_class('Automattic\\WooC...') #2 /htdocs/wp-content/plugins/woocommerce/src/StoreApi/deprecated.php(73): class_alias('Automattic\\WooC...', 'Automattic\\WooC...') #3 /htdocs/wp-content/plugins/jetpack/vendor/jetpack-autoloader/class-version-loader.php(89): require_once('/htdocs/wp-cont...') #4 /htdocs/wp-content/plugins/jetpack/vendor/jetpack-autoloader/class-autoloader-handler.php(124): Automattic\Jetpack\Autoloader\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ13_5\al3_0_8\Version_Loader->load_filemap() #5 /htdocs/wp-content/plugins/jetpack/vendor/jetpack-autoloader/class-autoloader.php(80): Automattic\Jetpack\Autoloader\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ13_5\al3_0_8\Autoloader_Handler->activate_autoloader(Array) #6 /htdocs/wp-content/plugins/jetpack/vendor/autoload_packages.php(13): Automattic\Jetpack\Autoloader\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ13_5\al3_0_8\Autoloader::init() #7 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/jetpack-autoloader/class-latest-autoloader-guard.php(80): require('/htdocs/wp-cont...') #8 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/jetpack-autoloader/class-autoloader.php(75): Automattic\Jetpack\Autoloader\jpdc1c866ff5a5faf503e7f4899f251f63\al3_0_2\Latest_Autoloader_Guard->should_stop_init('/htdocs/wp-cont...', Array, false) #9 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/autoload_packages.php(13): Automattic\Jetpack\Autoloader\jpdc1c866ff5a5faf503e7f4899f251f63\al3_0_2\Autoloader::init() #10 /htdocs/wp-content/plugins/google-listings-and-ads/src/Autoloader.php(37): require('/htdocs/wp-cont...') #11 /htdocs/wp-content/plugins/google-listings-and-ads/google-listings-and-ads.php(39): Automattic\WooCommerce\GoogleListingsAndAds\Autoloader::init() #12 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #13 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #14 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #15 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #16 /htdocs/index.php(17): require('/htdocs/wp-blog...') #17 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1/Cart.php on line 7