order_type The order type being set. * @param array $counts Normalized counts keyed by status slug * (e.g. [ 'wc-processing' => 10, 'wc-pending' => 5 ]). * * @return array|bool[] Success map from wp_cache_set_multiple(). */ public function set_multiple( string $order_type, array $counts ) { if ( empty( $counts ) ) { return array(); } $this->ensure_statuses_for_type( $order_type, array_keys( $counts ) ); $mapped_counts = array(); foreach ( $counts as $status => $count ) { $mapped_counts[ $this->get_cache_key( $order_type, $status ) ] = (int) $count; } return wp_cache_set_multiple( $mapped_counts, '', $this->expiration ); } /** * Get the cache value for a given order type and set of statuses. * * @param string $order_type The type of order. * @param string[] $order_statuses The statuses of the order. * @return int[] The cache value. */ public function get( $order_type, $order_statuses = array() ) { $order_type = (string) $order_type; if ( empty( $order_statuses ) ) { $order_statuses = $this->get_saved_statuses_for_type( $order_type ); if ( empty( $order_statuses ) ) { return null; } } $cache_keys = array_map( function( $order_statuses ) use ( $order_type ) { return $this->get_cache_key( $order_type, $order_statuses ); }, $order_statuses ); $cache_values = wp_cache_get_multiple( $cache_keys ); $status_values = array(); foreach ( $cache_values as $key => $value ) { // Return null for the entire cache if any of the requested statuses are not found because they fell out of cache. if ( $value === false ) { return null; } $order_status = str_replace( $this->get_cache_key( $order_type, '' ), '', $key ); $status_values[ $order_status ] = $value; } return $status_values; } /** * Increment the cache value for a given order status. * * @param string $order_type The type of order. * @param string $order_status The status of the order. * @param int $offset The amount to increment by. * @return int The new value of the cache. */ public function increment( $order_type, $order_status, $offset = 1 ) { $cache_key = $this->get_cache_key( $order_type, $order_status ); return wp_cache_incr( $cache_key, $offset ); } /** * Decrement the cache value for a given order status. * * @param string $order_type The type of order. * @param string $order_status The status of the order. * @param int $offset The amount to decrement by. * @return int The new value of the cache. */ public function decrement( $order_type, $order_status, $offset = 1 ) { $cache_key = $this->get_cache_key( $order_type, $order_status ); return wp_cache_decr( $cache_key, $offset ); } /** * Flush the cache for a given order type and statuses. * * @param string $order_type The type of order. * @param string[] $order_statuses The statuses of the order. * @return void */ public function flush( $order_type = 'shop_order', $order_statuses = array() ) { $order_type = (string) $order_type; $flush_saved_statuses = false; if ( empty( $order_statuses ) ) { $order_statuses = $this->get_saved_statuses_for_type( $order_type ); $flush_saved_statuses = true; } $cache_keys = array_map( function( $order_statuses ) use ( $order_type ) { return $this->get_cache_key( $order_type, $order_statuses ); }, $order_statuses ); if ( $flush_saved_statuses ) { // If all statuses are being flushed, go ahead and flush the status list so any permanently removed statuses are cleared out. $cache_keys[] = $this->get_saved_statuses_cache_key( $order_type ); } wp_cache_delete_multiple( $cache_keys ); } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Caches\OrderCountCache" not found in /htdocs/wp-content/plugins/woocommerce/src/Caches/OrderCountCacheService.php:47 Stack trace: #0 [internal function]: Automattic\WooCommerce\Caches\OrderCountCacheService->init() #1 /htdocs/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/RuntimeContainer.php(189): ReflectionMethod->invoke(Object(Automattic\WooCommerce\Caches\OrderCountCacheService)) #2 /htdocs/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/RuntimeContainer.php(116): Automattic\WooCommerce\Internal\DependencyManagement\RuntimeContainer->instantiate_class_using_reflection('Automattic\\WooC...', Array) #3 /htdocs/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/RuntimeContainer.php(75): Automattic\WooCommerce\Internal\DependencyManagement\RuntimeContainer->get_core('Automattic\\WooC...', Array) #4 /htdocs/wp-content/plugins/woocommerce/src/Container.php(67): Automattic\WooCommerce\Internal\DependencyManagement\RuntimeContainer->get('Automattic\\WooC...') #5 /htdocs/wp-content/plugins/woocommerce/includes/class-woocommerce.php(355): Automattic\WooCommerce\Container->get('Automattic\\WooC...') #6 /htdocs/wp-content/plugins/woocommerce/includes/class-woocommerce.php(255): WooCommerce->init_hooks() #7 /htdocs/wp-content/plugins/woocommerce/includes/class-woocommerce.php(162): WooCommerce->__construct() #8 /htdocs/wp-content/plugins/woocommerce/woocommerce.php(47): WooCommerce::instance() #9 /htdocs/wp-content/plugins/woocommerce/woocommerce.php(62): WC() #10 /htdocs/wp-settings.php(560): include_once('/htdocs/wp-cont...') #11 /htdocs/wp-config.php(102): require_once('/htdocs/wp-sett...') #12 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #13 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #14 /htdocs/index.php(17): require('/htdocs/wp-blog...') #15 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/Caches/OrderCountCacheService.php on line 47