How can we improve WooCommerce?

Import as draft, not published

My client imports new products from LS every couple of weeks, maybe adding 10 or 20 at a time. As she imports them, she immediately, goes and changes the Woo products (post) from "published" to "draft" -- as she likes to manage images and descriptions in WP. So she doesn't want them live immediately on import before she has added the description etc. So an option to "Import as draft" somewhere in the loaded products table would be great. Alternatively: I can see where the insert_post array is created, and the quicker fix for now might be to just have a filter on that, so a developer could change that to 'status' => 'draft'

11 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Bob Passaro shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    5 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Anonymous commented  ·   ·  Flag as inappropriate

        Here's another awesome way to do it (disclaimer: partially tested so far, but promising):

        add_filter( 'wp_insert_post_data', 'post_insert_handler', '99', 2 );
        function post_insert_handler($data,$postarr) {
        if (strpos($data["post_type"],"product")===0) $data["post_status"] = "draft";
        return $data;
        }

      • Bob Passaro commented  ·   ·  Flag as inappropriate

        Pretty simple snippet now for anyone who is interested:

        /**
        * Filter insert post array on import so that products come in as draft, not published.
        */

        add_filter( 'wclsi_import_post_fields_matrix_prod', 'mystore_import_product_as_draft' );
        add_filter( 'wclsi_import_post_fields_single_prod', 'mystore_import_product_as_draft' );

        function mystore_import_product_as_draft( $import_fields ) {
        $import_fields['post_status'] = 'draft';
        return $import_fields;
        }

      • Bob Passaro commented  ·   ·  Flag as inappropriate

        Oh, sorry, just noticed this, conschneider. Well I meant there is now a filter hook on the array where the Product post is created, so I can hook in and change 'status' => 'draft' without having to hack the plugin file :)

        I swear that hook wasn't there when I made the original request, but maybe it was and I missed it.

      WooCommerce: Extension - WooCommerce Lightspeed POS

      Feedback and Knowledge Base