s specific to the cart endpoint. * * @param array $product_images Array of image objects, as defined in ImageAttachmentSchema. * @param array $cart_item Cart item array. * @param string $cart_item_key Cart item key. * @since 9.6.0 */ $filtered_images = apply_filters( 'woocommerce_store_api_cart_item_images', $product_images, $cart_item, $cart_item_key ); if ( ! is_array( $filtered_images ) || count( $filtered_images ) === 0 ) { return $product_images; } // Return the original images if the filtered image has no ID, or an invalid thumbnail or source URL. $valid_images = array(); $logger = wc_get_logger(); foreach ( $filtered_images as $image ) { // If id is not set then something is wrong with the image, and further logging would break (it uses the ID). if ( ! isset( $image->id ) ) { $logger->warning( 'After passing through woocommerce_cart_item_images filter, one of the images did not have an id property.' ); continue; } // Check if thumbnail is a valid url. if ( empty( $image->thumbnail ) || ! filter_var( $image->thumbnail, FILTER_VALIDATE_URL ) ) { $logger->warning( sprintf( 'After passing through woocommerce_cart_item_images filter, image with id %s did not have a valid thumbnail property.', $image->id ) ); continue; } // Check if src is a valid url. if ( empty( $image->src ) || ! filter_var( $image->src, FILTER_VALIDATE_URL ) ) { $logger->warning( sprintf( 'After passing through woocommerce_cart_item_images filter, image with id %s did not have a valid src property.', $image->id ) ); continue; } // Image is valid, add to resulting array. $valid_images[] = $image; } // If there are no valid images remaining, return original array. if ( count( $valid_images ) === 0 ) { return $product_images; } // Return the filtered images. return $valid_images; } /** * Format cart item data removing any HTML tag. * * @param array $cart_item Cart item array. * @return array */ protected function get_item_data( $cart_item ) { /** * Filters cart item data. * * Filters the variation option name for custom option slugs. * * @since 4.3.0 * * @internal Matches filter name in WooCommerce core. * * @param array $item_data Cart item data. Empty by default. * @param array $cart_item Cart item array. * @return array */ $item_data = apply_filters( 'woocommerce_get_item_data', array(), $cart_item ); $clean_item_data = []; foreach ( $item_data as $data ) { // We will check each piece of data in the item data element to ensure it is scalar. Extensions could add arrays // to this, which would cause a fatal in wp_strip_all_tags. If it is not scalar, we will return an empty array, // which will be filtered out in get_item_data (after this function has run). foreach ( $data as $data_value ) { if ( ! is_scalar( $data_value ) ) { continue 2; } } $clean_item_data[] = $this->format_item_data_element( $data ); } return $clean_item_data; } /** * Remove HTML tags from cart item data and set the `hidden` property to `__experimental_woocommerce_blocks_hidden`. * * @param array $item_data_element Individual element of a cart item data. * @return array */ protected function format_item_data_element( $item_data_element ) { if ( array_key_exists( '__experimental_woocommerce_blocks_hidden', $item_data_element ) ) { $item_data_element['hidden'] = $item_data_element['__experimental_woocommerce_blocks_hidden']; } return array_map( 'wp_strip_all_tags', $item_data_element ); } }
Warning: Class "Automattic\WooCommerce\StoreApi\Schemas\V1\CartItemSchema" not found in /htdocs/wp-content/plugins/woocommerce/src/StoreApi/deprecated.php on line 73
s specific to the cart endpoint. * * @param array $product_images Array of image objects, as defined in ImageAttachmentSchema. * @param array $cart_item Cart item array. * @param string $cart_item_key Cart item key. * @since 9.6.0 */ $filtered_images = apply_filters( 'woocommerce_store_api_cart_item_images', $product_images, $cart_item, $cart_item_key ); if ( ! is_array( $filtered_images ) || count( $filtered_images ) === 0 ) { return $product_images; } // Return the original images if the filtered image has no ID, or an invalid thumbnail or source URL. $valid_images = array(); $logger = wc_get_logger(); foreach ( $filtered_images as $image ) { // If id is not set then something is wrong with the image, and further logging would break (it uses the ID). if ( ! isset( $image->id ) ) { $logger->warning( 'After passing through woocommerce_cart_item_images filter, one of the images did not have an id property.' ); continue; } // Check if thumbnail is a valid url. if ( empty( $image->thumbnail ) || ! filter_var( $image->thumbnail, FILTER_VALIDATE_URL ) ) { $logger->warning( sprintf( 'After passing through woocommerce_cart_item_images filter, image with id %s did not have a valid thumbnail property.', $image->id ) ); continue; } // Check if src is a valid url. if ( empty( $image->src ) || ! filter_var( $image->src, FILTER_VALIDATE_URL ) ) { $logger->warning( sprintf( 'After passing through woocommerce_cart_item_images filter, image with id %s did not have a valid src property.', $image->id ) ); continue; } // Image is valid, add to resulting array. $valid_images[] = $image; } // If there are no valid images remaining, return original array. if ( count( $valid_images ) === 0 ) { return $product_images; } // Return the filtered images. return $valid_images; } /** * Format cart item data removing any HTML tag. * * @param array $cart_item Cart item array. * @return array */ protected function get_item_data( $cart_item ) { /** * Filters cart item data. * * Filters the variation option name for custom option slugs. * * @since 4.3.0 * * @internal Matches filter name in WooCommerce core. * * @param array $item_data Cart item data. Empty by default. * @param array $cart_item Cart item array. * @return array */ $item_data = apply_filters( 'woocommerce_get_item_data', array(), $cart_item ); $clean_item_data = []; foreach ( $item_data as $data ) { // We will check each piece of data in the item data element to ensure it is scalar. Extensions could add arrays // to this, which would cause a fatal in wp_strip_all_tags. If it is not scalar, we will return an empty array, // which will be filtered out in get_item_data (after this function has run). foreach ( $data as $data_value ) { if ( ! is_scalar( $data_value ) ) { continue 2; } } $clean_item_data[] = $this->format_item_data_element( $data ); } return $clean_item_data; } /** * Remove HTML tags from cart item data and set the `hidden` property to `__experimental_woocommerce_blocks_hidden`. * * @param array $item_data_element Individual element of a cart item data. * @return array */ protected function format_item_data_element( $item_data_element ) { if ( array_key_exists( '__experimental_woocommerce_blocks_hidden', $item_data_element ) ) { $item_data_element['hidden'] = $item_data_element['__experimental_woocommerce_blocks_hidden']; } return array_map( 'wp_strip_all_tags', $item_data_element ); } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\StoreApi\Schemas\V1\CartItemSchema" not found in /htdocs/wp-content/plugins/woocommerce/src/StoreApi/Schemas/ExtendSchema.php:27 Stack trace: #0 /htdocs/wp-content/plugins/woocommerce/src/StoreApi/StoreApi.php(116): [constant expression]() #1 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/AbstractDependencyType.php(42): Automattic\WooCommerce\StoreApi\StoreApi::Automattic\WooCommerce\StoreApi\{closure}(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #2 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/SharedType.php(28): Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType->resolve_value(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #3 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/Container.php(96): Automattic\WooCommerce\Blocks\Registry\SharedType->get(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #4 /htdocs/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/RuntimeContainer.php(107): Automattic\WooCommerce\Blocks\Registry\Container->get('Automattic\\WooC...') #5 /htdocs/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/RuntimeContainer.php(182): Automattic\WooCommerce\Internal\DependencyManagement\RuntimeContainer->get_core('Automattic\\WooC...', Array) #6 [internal function]: Automattic\WooCommerce\Internal\DependencyManagement\RuntimeContainer->Automattic\WooCommerce\Internal\DependencyManagement\{closure}(Object(ReflectionParameter)) #7 /htdocs/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/RuntimeContainer.php(170): array_map(Object(Closure), Array) #8 /htdocs/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/RuntimeContainer.php(116): Automattic\WooCommerce\Internal\DependencyManagement\RuntimeContainer->instantiate_class_using_reflection('Automattic\\WooC...', Array) #9 /htdocs/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/RuntimeContainer.php(75): Automattic\WooCommerce\Internal\DependencyManagement\RuntimeContainer->get_core('Automattic\\WooC...', Array) #10 /htdocs/wp-content/plugins/woocommerce/src/Container.php(66): Automattic\WooCommerce\Internal\DependencyManagement\RuntimeContainer->get('Automattic\\WooC...') #11 /htdocs/wp-content/plugins/woocommerce/includes/class-woocommerce.php(345): Automattic\WooCommerce\Container->get('Automattic\\WooC...') #12 /htdocs/wp-content/plugins/woocommerce/includes/class-woocommerce.php(239): WooCommerce->init_hooks() #13 /htdocs/wp-content/plugins/woocommerce/includes/class-woocommerce.php(157): WooCommerce->__construct() #14 /htdocs/wp-content/plugins/woocommerce/woocommerce.php(47): WooCommerce::instance() #15 /htdocs/wp-content/plugins/woocommerce/woocommerce.php(62): WC() #16 /htdocs/wp-settings.php(545): include_once('/htdocs/wp-cont...') #17 /htdocs/wp-config.php(90): require_once('/htdocs/wp-sett...') #18 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #19 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #20 /htdocs/index.php(17): require('/htdocs/wp-blog...') #21 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/StoreApi/Schemas/ExtendSchema.php on line 27