WC_REST_Products_V1_Controller::get_downloads
Get the downloads for a product or product variation.
Метод класса: WC_REST_Products_V1_Controller{}
Хуков нет.
Возвращает
Массив.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_downloads( $product );
- $product(WC_Product|WC_Product_Variation) (обязательный)
- Product instance.
Код WC_REST_Products_V1_Controller::get_downloads() WC REST Products V1 Controller::get downloads WC 11.0.1
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;
}