WordPress at Your Fingertips
function is not described

WC_Customer_Download::get_download_count() public WC 1.0

Get download_count.

{} It's a method of the class: WC_Customer_Download{}

No Hooks.

Return

Int.

Usage

$WC_Customer_Download = new WC_Customer_Download();
$WC_Customer_Download->get_download_count( $context );
$context(string)
What the value is for. Valid values are 'view' and 'edit'.
Default: 'view'

Code of WC_Customer_Download::get_download_count() WC 5.8.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 );
}