I am trying to create a WooCommerce product programmaticly. Everything works except the actuall file that can be downloaded after purchase. The image is in the correct folder and the code actually retrieves it. However upon execution the downloadable file will not be set. How can I fix this issue?
public function add_product(){
$product_1 = array(
'post_title' => "Test product",
'post_content' => "This is a temporary description",
'post_status' => 'draft',
'post_type' => "product"
);
$downloadable_file = array(
'id' => '1',
'name' => "Actuall downloadable file",
'file' => "../wp-content/uploads/2021/08/1149.jpg",
);
$downloadPicture = serialize($downloadable_file);
$post_id = wp_insert_post( $product_1 );
update_post_meta( $post_id, '_visibility', 'visible' );
update_post_meta( $post_id, '_stock_status', 'instock');
update_post_meta( $post_id, 'total_sales', '0' );
update_post_meta( $post_id, '_downloadable', 'yes' );
update_post_meta( $post_id, '_virtual', 'yes' );
update_post_meta( $post_id, '_sku', '54684845' );
update_post_meta( $post_id, '_regular_price', '75' );
` update_post_meta( $post_id, '_thumbnail_id', "../wp-content/uploads/2021/08/1149.jpg" );
update_post_meta( $post_id, '_downloadable_files', $downloadPicture );
}