protected function update_downloads(&$product)
{
$downloads = $product->get_downloads();
$meta_values = array();
if ($downloads) {
foreach ($downloads as $key => $download) {
// Store in format WC uses in meta.
$meta_values[$key] = $download->get_data();
}
}
if ($product->is_type('variation')) {
do_action('woocommerce_process_product_file_download_paths', $product->get_parent_id(), $product->get_id(), $downloads);
} else {
do_action('woocommerce_process_product_file_download_paths', $product->get_id(), 0, $downloads);
}
update_post_meta($product->get_id(), '_downloadable_files', $meta_values);
}