title: Add downloads in Woocommerce downloadable product programmatically
body: <p>I am creating a Woocommerce site where I wanna give vendors to upload products from their front end. But I stuck on a point where I am trying to add woocommerce downloadable products.</p>
  
  <p>Here is my current code: </p>
  
  <pre><code>//Let's upload the download file Zip 
      $zipattachment_id = upload_music_files($music_ID, $musicZip); //This is my custom function which returns attachment id after file upload
  
      $download_file_name = $musicZip['name'];
      $download_file_url  = wp_get_attachment_url($zipattachment_id);
      $md5_download_num = md5( $download_file_url );
  
      //creating array of download product
      $downloadable_file[$md5_download_num] = array(
          'id'   =&gt;  $md5_download_num,
          'name'   =&gt;  $download_file_name,
          'file'   =&gt;  $download_file_url,
          'previous_hash' =&gt; ''
      );
      $downloadMusic = serialize($downloadable_file);
  
      // adding downloadble file with the new array
      add_post_meta( $music_ID, '_downloadable_files', $downloadMusic );
  </code></pre>
  
  <p>But when I open the product edit from backend no downloadable files exits.</p>
  
  <p>Here is example return of the seriallized array : </p>
  
  <pre><code>a:1:{s:32:"22618d7f028803f57f98ab6b21277387";a:4:{s:2:"id";s:32:"22618d7f028803f57f98ab6b21277387";s:4:"name";s:5:"1.zip";s:4:"file";s:71:"http://mydomain/wp-content/uploads/2017/12/5a2e22cecaca6_1.zip";s:13:"previous_hash";s:0:"";}}
  </code></pre>
  
  <p>I am working with the latest version of woocommerce, can anybody suggest me what I am doing wrong and what can be the right way?</p>