How to change status of Products in Woocommerce | themelocation

How to change status of Products in Woocommerce?

In this tutorial; We will learn how to mark status of all products to draft or any other status. We will achieve this by using a simple query.

Although We can simple update status using bulk edit but if we have large number of products WordPress may give us a time out error.

Let’s get along with it. I have a few products in my store marked as published.

2015-09-08_1122

Let’s say I want to change the status of these products to ‘draft’. To do this we need to execute following query either in phpmyadmin or any GUI db management tool.

UPDATE wp_posts 
SET post_status='publish'
WHERE post_type='product'

2015-09-08_1125

After executing the query status of all products will be changed to draft.

Now, let’s say we just want to update status of products within a specific category. To do this we need to execute following query:

UPDATE wp_posts p 
JOIN wp_term_relationships r on p.id=r.object_id 
SET p.post_status='draft' 
WHERE r.term_taxonomy_id in (9, 10);

Replace the category ids in the query with ids of your categories. It will change the status of the products in specific categories. Thanks

No comments yet.

Leave a Reply