WC_Product::get_downloads PHP 메소드

get_downloads() 공개 메소드

Get downloads.
부터: 2.7.0
public get_downloads ( string $context = 'view' ) : array
$context string
리턴 array
    public function get_downloads($context = 'view')
    {
        return $this->get_prop('downloads', $context);
    }

Usage Example

 /**
  * 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;
 }
WC_Product