WC_API_Products::get_downloads() private WC 2.1
Get the downloads for a product or product variation
{} It's a method of the class: WC_API_Products{}
No Hooks.
Return
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_downloads( $product );
$product *(WC_Product | WC_Product_Variation) (required)* |
---|
Changelog
Since 2.1 | Introduced. |
Code of WC_API_Products::get_downloads() WC API Products::get downloads WC 5.0.0
private function get_downloads( $product ) {
$downloads = array();
if ( $product->is_downloadable() ) {
foreach ( $product->get_downloads() as $file_id => $file ) {
$downloads[] = array(
'id' => $file_id, // do not cast as int as this is a hash
'name' => $file['name'],
'file' => $file['file'],
);
}
}
return $downloads;
}