WC_REST_Product_Variations_Controller::get_downloads()
Get the downloads for a product variation.
Метод класса: WC_REST_Product_Variations_Controller{}
Хуков нет.
Возвращает
Массив
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_downloads( $product, $context );
- $product(WC_Product_Variation) (обязательный)
- Product variation instance.
- $context(строка)
- Context of the request: 'view' or 'edit'.
По умолчанию: 'view'
Код WC_REST_Product_Variations_Controller::get_downloads() WC REST Product Variations Controller::get downloads WC 9.5.1
protected function get_downloads( $product, $context = 'view' ) { $downloads = array(); if ( $product->is_downloadable() || 'edit' === $context ) { foreach ( $product->get_downloads() as $file_id => $file ) { $downloads[] = array( 'id' => $file_id, // MD5 hash. 'name' => $file['name'], 'file' => $file['file'], ); } } return $downloads; }