Automattic\WooCommerce\Caches
ProductCountCache::set_multiple
Deprecated since 11.1.0. It is no longer supported and may be removed in future releases. It is recommended to replace this function with the same one.
Set the cache count value for multiple statuses at once.
Method of the class: ProductCountCache{}
No Hooks.
Returns
array<string,bool>.
Usage
$ProductCountCache = new ProductCountCache(); $ProductCountCache->set_multiple( $product_type, $counts );
- $product_type(string) (required)
- The post type (e.g.
'product', 'product_variation'). - $counts(array<string,int>) (required)
- Counts keyed by status slug (e.g. [
'publish'=> 10,'draft'=> 5 ]).
Changelog
| Deprecated since | 11.1.0 |
ProductCountCache::set_multiple() ProductCountCache::set multiple code WC 11.1.2
public function set_multiple( string $product_type, array $counts ) {
$results = array();
foreach ( $counts as $status => $count ) {
$results[ $this->get_cache_key( $product_type, (string) $status ) ] = $this->set( $product_type, (string) $status, (int) $count );
}
return $results;
}