WC_Customer_Download::get_download_count()publicWC 1.0

Get download_count.

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

Хуков нет.

Возвращает

Int.

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

$WC_Customer_Download = new WC_Customer_Download();
$WC_Customer_Download->get_download_count( $context );
$context(строка)
What the value is for. Valid values are 'view' and 'edit'.
По умолчанию: 'view'

Код WC_Customer_Download::get_download_count() WC 8.7.0

public function get_download_count( $context = 'view' ) {
	// Check for count of download logs.
	$data_store       = WC_Data_Store::load( 'customer-download-log' );
	$download_log_ids = $data_store->get_download_logs_for_permission( $this->get_id() );

	$download_log_count = 0;
	if ( ! empty( $download_log_ids ) ) {
		$download_log_count = count( $download_log_ids );
	}

	// Check download count in prop.
	$download_count_prop = $this->get_prop( 'download_count', $context );

	// Return the larger of the two in case they differ.
	// If logs are removed for some reason, we should still respect the
	// count stored in the prop.
	return max( $download_log_count, $download_count_prop );
}