Automattic\WooCommerce\Caches
OrderCountCache::flush
Flush the cache for a given order type and statuses.
Method of the class: OrderCountCache{}
No Hooks.
Returns
null. Nothing (null).
Usage
$OrderCountCache = new OrderCountCache(); $OrderCountCache->flush( $order_type, $order_statuses );
- $order_type(string)
- The type of order.
Default:'shop_order' - $order_statuses(string[])
- The statuses of the order.
Default:array()
OrderCountCache::flush() OrderCountCache::flush code WC 10.7.0
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 );
}