From 621229b89425dd47b0a3637ecf1bd5b761d18e66 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 14 Feb 2019 15:05:10 +0000 Subject: [PATCH 1/2] Variations cannot be drafts - set to private. --- includes/import/abstract-wc-product-importer.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/import/abstract-wc-product-importer.php b/includes/import/abstract-wc-product-importer.php index 5fbfcf504b7..96a4453a362 100644 --- a/includes/import/abstract-wc-product-importer.php +++ b/includes/import/abstract-wc-product-importer.php @@ -236,6 +236,12 @@ abstract class WC_Product_Importer implements WC_Importer_Interface { unset( $data['manage_stock'], $data['stock_status'], $data['backorders'], $data['low_stock_amount'] ); } + if ( 'variation' === $object->get_type() ) { + if ( isset( $data['status'] ) && -1 === $data['status'] ) { + $data['status'] = 0; // Variations cannot be drafts - set to private. + } + } + if ( 'importing' === $object->get_status() ) { $object->set_status( 'publish' ); $object->set_slug( '' ); From 8c2e30582360bea34ce019d92126fea31d242024 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 14 Feb 2019 15:05:56 +0000 Subject: [PATCH 2/2] phpcs --- .../import/abstract-wc-product-importer.php | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/includes/import/abstract-wc-product-importer.php b/includes/import/abstract-wc-product-importer.php index 96a4453a362..8734a1ed978 100644 --- a/includes/import/abstract-wc-product-importer.php +++ b/includes/import/abstract-wc-product-importer.php @@ -650,13 +650,15 @@ abstract class WC_Product_Importer implements WC_Importer_Interface { } // If the attribute does not exist, create it. - $attribute_id = wc_create_attribute( array( - 'name' => $raw_name, - 'slug' => $attribute_name, - 'type' => 'select', - 'order_by' => 'menu_order', - 'has_archives' => false, - ) ); + $attribute_id = wc_create_attribute( + array( + 'name' => $raw_name, + 'slug' => $attribute_name, + 'type' => 'select', + 'order_by' => 'menu_order', + 'has_archives' => false, + ) + ); if ( is_wp_error( $attribute_id ) ) { throw new Exception( $attribute_id->get_error_message(), 400 ); @@ -667,15 +669,18 @@ abstract class WC_Product_Importer implements WC_Importer_Interface { register_taxonomy( $taxonomy_name, apply_filters( 'woocommerce_taxonomy_objects_' . $taxonomy_name, array( 'product' ) ), - apply_filters( 'woocommerce_taxonomy_args_' . $taxonomy_name, array( - 'labels' => array( - 'name' => $raw_name, - ), - 'hierarchical' => true, - 'show_ui' => false, - 'query_var' => true, - 'rewrite' => false, - ) ) + apply_filters( + 'woocommerce_taxonomy_args_' . $taxonomy_name, + array( + 'labels' => array( + 'name' => $raw_name, + ), + 'hierarchical' => true, + 'show_ui' => false, + 'query_var' => true, + 'rewrite' => false, + ) + ) ); // Set product attributes global.