Automattic\WooCommerce\Caches

OrderCountCache::ensure_statuses_for_typeprivateWC 1.0

Adds the given statuses to the cached statuses array for the order type if they are not already stored.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->ensure_statuses_for_type( $order_type, $order_statuses );
$order_type(строка) (обязательный)
The order type to save with.
$order_statuses(string[]) (обязательный)
One or more normalised statuses to add.

Код OrderCountCache::ensure_statuses_for_type() WC 11.0.1

private function ensure_statuses_for_type( string $order_type, array $order_statuses ) {
	if ( empty( $order_statuses ) ) {
		return;
	}

	$existing     = $this->get_saved_statuses_for_type( $order_type );
	$new_statuses = array_diff( $order_statuses, $existing );
	if ( empty( $new_statuses ) ) {
		return;
	}
	$merged = array_unique( array_merge( $existing, $new_statuses ) );

	wp_cache_set( $this->get_saved_statuses_cache_key( $order_type ), $merged, '', $this->expiration );
}