Automattic\WooCommerce\Caches

OrderCountCache::flushpublicWC 1.0

Flush the cache for a given order type and statuses.

Метод класса: OrderCountCache{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$OrderCountCache = new OrderCountCache();
$OrderCountCache->flush( $order_type, $order_statuses );
$order_type(строка)
The type of order.
По умолчанию: 'shop_order'
$order_statuses(string[])
The statuses to flush. Flushes all known statuses if empty.
По умолчанию: array()

Код OrderCountCache::flush() WC 11.0.1

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(
		fn( $order_statuses ) => $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 );
}