download() public static method

Download a file - hook into init function.
public static download ( string $file_path, integer $product_id )
$file_path string URL to file
$product_id integer of the product being downloaded
 /**
  * Admin voucher download, which will work regardless of the download
  * permissions/current user, and will not count towards the download
  * count
  *
  * @since 2.1
  */
 public function download_voucher()
 {
     if (isset($_GET['post']) && isset($_GET['product_id']) && isset($_GET['item_id']) && isset($_GET['action']) && 'download' == $_GET['action'] && $_GET['voucher_id']) {
         $order = wc_get_order($_GET['post']);
         $items = $order->get_items();
         $voucher = new WC_Voucher($_GET['voucher_id'], $_GET['post'], $items[$_GET['item_id']], $_GET['item_id']);
         $download_handler = new WC_Download_Handler();
         $file_path = $voucher->get_voucher_full_filename(WC_PDF_Product_Vouchers::get_uploads_path());
         if ('redirect' === get_option('woocommerce_file_download_method')) {
             $file_path = $voucher->convert_path_to_url($file_path);
         }
         $download_handler->download($file_path, $_GET['product_id']);
         exit;
     }
 }