Reputation: 21
As the title describes i want to delete all the out of stock products from my woocommerce eshop at the end of the day. Every day morning i import 6000 products with their images from another server and 600-700 are out of stock. So every day i upload 700 trash in my server and i have to delete manually at the end of the day cause server data limitations. I found these related questions
How to move out of stock product to trash Woocommerce?
Woocommerce delete products which are "Out of stock"
but the problem is that if i run one of these sql codes in functions.php file the products can be deleted but the thumbnails and images of the products are remain in my server and i have to delete manually.
Upvotes: 0
Views: 984
Reputation: 77
I would prevent the out or stock products from being imported in the first place?
How are you importing these products in the first place? The import takes place, usually via a CSV which can contain as little or as much information as you require. One column is called 'In stock?' with either a value of 1 for in stock, or 0 for out of stock.
So in your import file you can just remove the products that have a value of 0 for 'In stock?' and then carry on as normal. That way no images etc will be imported.
Upvotes: 1