WC_Customer_Download::get_download_count( string $context = 'view' )
Get download_count.
Description Description
Parameters Parameters
- $context
-
(Optional) What the value is for. Valid values are 'view' and 'edit'.
Default value: 'view'
Return Return
(integer)
Source Source
File: includes/class-wc-customer-download.php
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 ); }