diff --git a/includes/admin/importers/class-wc-product-csv-importer-controller.php b/includes/admin/importers/class-wc-product-csv-importer-controller.php index 0de82507fdc..b14ad20f453 100644 --- a/includes/admin/importers/class-wc-product-csv-importer-controller.php +++ b/includes/admin/importers/class-wc-product-csv-importer-controller.php @@ -566,6 +566,8 @@ class WC_Product_CSV_Importer_Controller { /* translators: %d: Attribute number */ __( 'Attribute %d default', 'woocommerce' ) => 'attributes:default', /* translators: %d: Download number */ + __( 'Download %d ID', 'woocommerce' ) => 'downloads:id', + /* translators: %d: Download number */ __( 'Download %d name', 'woocommerce' ) => 'downloads:name', /* translators: %d: Download number */ __( 'Download %d URL', 'woocommerce' ) => 'downloads:url', @@ -721,6 +723,7 @@ class WC_Product_CSV_Importer_Controller { 'downloads' => array( 'name' => __( 'Downloads', 'woocommerce' ), 'options' => array( + 'downloads:id' . $index => __( 'Download ID', 'woocommerce' ), 'downloads:name' . $index => __( 'Download name', 'woocommerce' ), 'downloads:url' . $index => __( 'Download URL', 'woocommerce' ), 'download_limit' => __( 'Download limit', 'woocommerce' ), diff --git a/includes/admin/importers/mappings/default.php b/includes/admin/importers/mappings/default.php index 4de9337d89c..0d9599da04c 100644 --- a/includes/admin/importers/mappings/default.php +++ b/includes/admin/importers/mappings/default.php @@ -102,6 +102,7 @@ function wc_importer_default_special_english_mappings( $mappings ) { 'Attribute %d visible' => 'attributes:visible', 'Attribute %d global' => 'attributes:taxonomy', 'Attribute %d default' => 'attributes:default', + 'Download %d ID' => 'downloads:id', 'Download %d name' => 'downloads:name', 'Download %d URL' => 'downloads:url', 'Meta: %s' => 'meta:', diff --git a/includes/import/class-wc-product-csv-importer.php b/includes/import/class-wc-product-csv-importer.php index c9c11f44684..78d65f789bb 100644 --- a/includes/import/class-wc-product-csv-importer.php +++ b/includes/import/class-wc-product-csv-importer.php @@ -894,6 +894,12 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { } unset( $data[ $key ] ); + } elseif ( $this->starts_with( $key, 'downloads:id' ) ) { + if ( ! empty( $value ) ) { + $downloads[ str_replace( 'downloads:id', '', $key ) ]['id'] = $value; + } + unset( $data[ $key ] ); + } elseif ( $this->starts_with( $key, 'downloads:name' ) ) { if ( ! empty( $value ) ) { $downloads[ str_replace( 'downloads:name', '', $key ) ]['name'] = $value; @@ -935,8 +941,9 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { } $data['downloads'][] = array( - 'name' => $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['url'] ), - 'file' => $file['url'], + 'download_id' => isset( $file['id'] ) ? $file['id'] : null, + 'name' => $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['url'] ), + 'file' => $file['url'], ); } }