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

Automattic\WooCommerce\Internal

DownloadPermissionsAdjuster::get_download_files_and_permissions() private WC 1.0

Get the existing downloadable files and download permissions for a given product. The returned value is an array with two keys:

  • download_ids_by_file_url: an associative array of file url => download_id.
  • permission_data_by_file_order_user: an associative array where key is "file_url:customer_id:order_id" and value is the full permission data set.

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

Хуков нет.

Возвращает

Массив[]. Information about the downloadable files and permissions for the product.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_download_files_and_permissions( \WC_Product $product );
\WC_Product $product (обязательный)
-

Код DownloadPermissionsAdjuster::get_download_files_and_permissions() WC 5.0.0

<?php
private function get_download_files_and_permissions( \WC_Product $product ) {
	$result    = array(
		'permission_data_by_file_order_user' => array(),
		'download_ids_by_file_url'           => array(),
	);
	$downloads = $product->get_downloads();
	foreach ( $downloads as $download ) {
		$result['download_ids_by_file_url'][ $download->get_file() ] = $download->get_id();
	}

	$permissions = $this->downloads_data_store->get_downloads( array( 'product_id' => $product->get_id() ) );
	foreach ( $permissions as $permission ) {
		$permission_data = (array) $permission->data;
		if ( array_key_exists( $permission_data['download_id'], $downloads ) ) {
			$file = $downloads[ $permission_data['download_id'] ]->get_file();
			$data = array(
				'file' => $file,
				'data' => (array) $permission->data,
			);
			$result['permission_data_by_file_order_user'][ "${file}:${permission_data['user_id']}:${permission_data['order_id']}" ] = $data;
		}
	}

	return $result;
}