WC_Order_Item_Product::get_item_downloads() public WC 1.0
Get any associated downloadable files.
{} Это метод класса: WC_Order_Item_Product{}
Хуки из метода
Возвращает
Массив.
Использование
$WC_Order_Item_Product = new WC_Order_Item_Product(); $WC_Order_Item_Product->get_item_downloads();
Код WC_Order_Item_Product::get_item_downloads() WC Order Item Product::get item downloads WC 5.0.0
public function get_item_downloads() {
$files = array();
$product = $this->get_product();
$order = $this->get_order();
$product_id = $this->get_variation_id() ? $this->get_variation_id() : $this->get_product_id();
if ( $product && $order && $product->is_downloadable() && $order->is_download_permitted() ) {
$email_hash = function_exists( 'hash' ) ? hash( 'sha256', $order->get_billing_email() ) : sha1( $order->get_billing_email() );
$data_store = WC_Data_Store::load( 'customer-download' );
$customer_downloads = $data_store->get_downloads(
array(
'user_email' => $order->get_billing_email(),
'order_id' => $order->get_id(),
'product_id' => $product_id,
)
);
foreach ( $customer_downloads as $customer_download ) {
$download_id = $customer_download->get_download_id();
if ( $product->has_file( $download_id ) ) {
$file = $product->get_file( $download_id );
$files[ $download_id ] = $file->get_data();
$files[ $download_id ]['downloads_remaining'] = $customer_download->get_downloads_remaining();
$files[ $download_id ]['access_expires'] = $customer_download->get_access_expires();
$files[ $download_id ]['download_url'] = add_query_arg(
array(
'download_file' => $product_id,
'order' => $order->get_order_key(),
'uid' => $email_hash,
'key' => $download_id,
),
trailingslashit( home_url() )
);
}
}
}
return apply_filters( 'woocommerce_get_item_downloads', $files, $this, $order );
}