skip to Main Content

I have a woocommerce store and I want to make all the products ( including variable products ) quantity to 0. So, all the products will be out of stock. I am not getting any plugin to do it. I have atleast 2100 products in the inventory. So, it is not feasible to do it manually. Is there any other way I can do this automatically ?

Thanks.

2

Answers


  1. Install PhpMyAdmin plugin and directly edit the quantities in the relevant database table.

    Login or Signup to reply.
  2. You can paste this code in your functions.php in your child theme.

    $products = $wpdb->get_results("SELECT * FROM `".$wpdb->postmeta."`");
    foreach($products as $product){
        if(get_post_type($product->post_id) == "product"){
            $product_id = $product->post_id;
            wc_update_product_stock($product_id, 0, 'set');
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search