Automattic\WooCommerce\Caches
OrderCountCache::get
Get the cache value for a given order type and set of statuses.
Method of the class: OrderCountCache{}
No Hooks.
Returns
null|Array
Usage
$OrderCountCache = new OrderCountCache(); $OrderCountCache->get( $order_type, $order_statuses );
- $order_type(string) (required)
- The type of order.
- $order_statuses(string[])
- The statuses of the order.
Default:array()
OrderCountCache::get() OrderCountCache::get code WC 10.8.1
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;
}