Importing WooCommerce product as draft

by dragoeco   Last Updated October 17, 2019 15:08 PM

I’m importing products from a platform directly to my shop in a category named “pending”. I have to make some modifications (change image, text, HTML/CSS…) before publishing them so I need all these products to be not published when they're imported.

I wonder to know if there is a possibility to set automatically all the products from this specific category as "draft"?

I use this snippet (found here) to hide all products from this category but they still appear in some location of my theme (latest product widget, related product...).

add_action( 'woocommerce_product_query', 'bbloomer_hide_products_category_shop' );       
function bbloomer_hide_products_category_shop( $q ) {      
    $tax_query = (array) $q->get( 'tax_query' );      
    $tax_query[] = array(
           'taxonomy' => 'product_cat',
           'field' => 'slug',
           'terms' => array( 'chairs' ), // Category slug here
           'operator' => 'NOT IN'
    $q->set( 'tax_query', $tax_query );      

Setting all these products as "draft" would be the best solution for me so if anyone could give me a clue on how to achieve this (or if it's even possible), that would be great :)

Related Questions

product images not seen on shop page

Updated April 02, 2018 11:08 AM

wp_insert_post when looping through large file

Updated June 27, 2019 15:08 PM

How to speed up products import

Updated August 28, 2017 15:08 PM

Internal Server Error - With CSV Import on WordPress

Updated February 22, 2017 07:08 AM