From fa4e55bca38bd839f59b6a1bc1cf03d4ac367ad8 Mon Sep 17 00:00:00 2001 From: Shamali Sulakhe Date: Thu, 17 Oct 2019 19:14:37 +0530 Subject: [PATCH] Showed filename when product CSV import is finished - issue #24266 --- assets/js/admin/wc-product-import.js | 3 ++- .../class-wc-product-csv-importer-controller.php | 11 ++++++----- .../admin/importers/views/html-csv-import-done.php | 8 ++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/assets/js/admin/wc-product-import.js b/assets/js/admin/wc-product-import.js index 0af872bcd8a..967d84f6ef5 100644 --- a/assets/js/admin/wc-product-import.js +++ b/assets/js/admin/wc-product-import.js @@ -58,7 +58,8 @@ $this.$form.find('.woocommerce-importer-progress').val( response.data.percentage ); if ( 'done' === response.data.position ) { - window.location = response.data.url + '&products-imported=' + parseInt( $this.imported, 10 ) + '&products-failed=' + parseInt( $this.failed, 10 ) + '&products-updated=' + parseInt( $this.updated, 10 ) + '&products-skipped=' + parseInt( $this.skipped, 10 ); + var file_name = wc_product_import_params.file.split('/').pop(); + window.location = response.data.url + '&products-imported=' + parseInt( $this.imported, 10 ) + '&products-failed=' + parseInt( $this.failed, 10 ) + '&products-updated=' + parseInt( $this.updated, 10 ) + '&products-skipped=' + parseInt( $this.skipped, 10 )+'&file-name='+file_name; } else { $this.run_import(); } 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 fbd20e779d6..104115b7387 100644 --- a/includes/admin/importers/class-wc-product-csv-importer-controller.php +++ b/includes/admin/importers/class-wc-product-csv-importer-controller.php @@ -455,11 +455,12 @@ class WC_Product_CSV_Importer_Controller { */ protected function done() { check_admin_referer( 'woocommerce-csv-importer' ); - $imported = isset( $_GET['products-imported'] ) ? absint( $_GET['products-imported'] ) : 0; - $updated = isset( $_GET['products-updated'] ) ? absint( $_GET['products-updated'] ) : 0; - $failed = isset( $_GET['products-failed'] ) ? absint( $_GET['products-failed'] ) : 0; - $skipped = isset( $_GET['products-skipped'] ) ? absint( $_GET['products-skipped'] ) : 0; - $errors = array_filter( (array) get_user_option( 'product_import_error_log' ) ); + $imported = isset( $_GET['products-imported'] ) ? absint( $_GET['products-imported'] ) : 0; + $updated = isset( $_GET['products-updated'] ) ? absint( $_GET['products-updated'] ) : 0; + $failed = isset( $_GET['products-failed'] ) ? absint( $_GET['products-failed'] ) : 0; + $skipped = isset( $_GET['products-skipped'] ) ? absint( $_GET['products-skipped'] ) : 0; + $file_name = isset( $_GET['file-name'] ) ? sanitize_text_field( wp_unslash( $_GET['file-name'] ) ) : ''; + $errors = array_filter( (array) get_user_option( 'product_import_error_log' ) ); include_once dirname( __FILE__ ) . '/views/html-csv-import-done.php'; } diff --git a/includes/admin/importers/views/html-csv-import-done.php b/includes/admin/importers/views/html-csv-import-done.php index 3f43869edb8..1774001d014 100644 --- a/includes/admin/importers/views/html-csv-import-done.php +++ b/includes/admin/importers/views/html-csv-import-done.php @@ -50,6 +50,14 @@ if ( ! defined( 'ABSPATH' ) ) { $results[] = '' . __( 'View import log', 'woocommerce' ) . ''; } + if ( ! empty( $file_name ) ) { + $results[] = sprintf( + /* translators: %s: File name */ + __( 'File uploaded: %s', 'woocommerce' ), + '' . $file_name . '' + ); + } + /* translators: %d: import results */ echo wp_kses_post( __( 'Import complete!', 'woocommerce' ) . ' ' . implode( '. ', $results ) ); ?>