/** * Get the downloads for a product or product variation * * @since 2.1 * @param WC_Product|WC_Product_Variation $product * @return array */ private function get_downloads($product) { $downloads = array(); if ($product->is_downloadable()) { foreach ($product->get_downloads() as $file_id => $file) { $downloads[] = array('id' => $file_id, 'name' => $file['name'], 'file' => $file['file']); } } return $downloads; }