Automattic\WooCommerce\Caches
OrderCountCache::set_multiple
Set the cache count value for multiple statuses at once.
Method of the class: OrderCountCache{}
No Hooks.
Returns
Array|true|false[]. Success map from wp_cache_set_multiple().
Usage
$OrderCountCache = new OrderCountCache(); $OrderCountCache->set_multiple( $order_type, $counts );
- $order_type(string) (required)
- The order type being set.
- $counts(array) (required)
- Normalized counts keyed by status slug (e.g. [
'wc-processing'=> 10,'wc-pending'=> 5 ]).
OrderCountCache::set_multiple() OrderCountCache::set multiple code WC 10.8.1
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 );
}