WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Customer_Download::track_download() public WC 3.3.0

Track a download on this permission.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

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

Хуков нет.

Возвращает

null. Ничего.

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

$WC_Customer_Download = new WC_Customer_Download();
$WC_Customer_Download->track_download( $user_id, $user_ip_address );
$user_id(int)
Id of the user performing the download.
По умолчанию: null
$user_ip_address(строка)
IP Address of the user performing the download.
По умолчанию: null

Список изменений

С версии 3.3.0 Введена.

Код WC_Customer_Download::track_download() WC 5.9.0

public function track_download( $user_id = null, $user_ip_address = null ) {
	global $wpdb;

	// Must have a permission_id to track download log.
	if ( ! ( $this->get_id() > 0 ) ) {
		throw new Exception( __( 'Invalid permission ID.', 'woocommerce' ) );
	}

	// Increment download count, and decrement downloads remaining.
	// Use SQL to avoid possible issues with downloads in quick succession.
	// If downloads_remaining is blank, leave it blank (unlimited).
	// Also, ensure downloads_remaining doesn't drop below zero.
	$query = $wpdb->prepare(
		"
UPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions
SET download_count = download_count + 1,
downloads_remaining = IF( downloads_remaining = '', '', GREATEST( 0, downloads_remaining - 1 ) )
WHERE permission_id = %d",
		$this->get_id()
	);
	$wpdb->query( $query ); // WPCS: unprepared SQL ok.

	// Re-read this download from the data store to pull updated counts.
	$this->data_store->read( $this );

	// Track download in download log.
	$download_log = new WC_Customer_Download_Log();
	$download_log->set_timestamp( current_time( 'timestamp', true ) );
	$download_log->set_permission_id( $this->get_id() );

	if ( ! is_null( $user_id ) ) {
		$download_log->set_user_id( $user_id );
	}

	if ( ! is_null( $user_ip_address ) ) {
		$download_log->set_user_ip_address( $user_ip_address );
	}

	$download_log->save();
}