diff --git a/includes/import/class-wc-product-csv-importer.php b/includes/import/class-wc-product-csv-importer.php index 6ee73992898..1609cf94ebc 100644 --- a/includes/import/class-wc-product-csv-importer.php +++ b/includes/import/class-wc-product-csv-importer.php @@ -582,12 +582,6 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { protected function expand_data( $data ) { $data = apply_filters( 'woocommerce_product_importer_pre_expand_data', $data ); - // Status is mapped from a special published field. - if ( isset( $data['published'] ) ) { - $data['status'] = ( $data['published'] ? 'publish' : 'draft' ); - unset( $data['published'] ); - } - // Images field maps to image and gallery id fields. if ( isset( $data['images'] ) ) { $images = $data['images']; @@ -609,6 +603,13 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { $data['type'] = current( array_diff( $data['type'], array( 'virtual', 'downloadable' ) ) ); } + // Status is mapped from a special published field. + if ( isset( $data['published'] ) ) { + $non_published_status = isset( $data['type'] ) && 'variation' === $data['type'] ? 'private' : 'draft'; + $data['status'] = ( $data['published'] ? 'publish' : $non_published_status ); + unset( $data['published'] ); + } + if ( isset( $data['stock_quantity'] ) ) { if ( '' === $data['stock_quantity'] ) { $data['manage_stock'] = false;