WC_REST_Products_V2_Controller::get_downloads() protected WC 1.0
Get the downloads for a product or product variation.
{} It's a method of the class: WC_REST_Products_V2_Controller{}
No Hooks.
Return
Array.
Usage
// protected - for code of main (parent) or child class $result = $this->get_downloads( $product );
- $product(WC_Product|WC_Product_Variation) (required)
- Product instance.
Code of WC_REST_Products_V2_Controller::get_downloads() WC REST Products V2 Controller::get downloads WC 5.0.0
protected function get_downloads( $product ) {
$downloads = array();
if ( $product->is_downloadable() ) {
foreach ( $product->get_downloads() as $file_id => $file ) {
$downloads[] = array(
'id' => $file_id, // MD5 hash.
'name' => $file['name'],
'file' => $file['file'],
);
}
}
return $downloads;
}