How to bulk delete woocommerce products | Woocommerce bulk delete SQL script

In this article, learn how to How to bulk delete woocommerce products by running simple SQL command through PhpMyAdmin.


How to bulk delete woocommerce products | Woocommerce bulk delete SQL script

Please follow the below steps to bulk delete woocommerce products by running simple SQL command through PhpMyAdmin. Please take the backup of your database before proceeding to bulk delete products from your woocommerce database.

  • Login to your CPanel and open the PhpMyAdmin application
  • Select your database. Once the database is selected, select the wp_posts table. (Note: wp_post is the default post table name. If you have changed the table prefix during wordpress installation, the name will be different. For example, abwp_999post
  • Once the wp_post table is selected, selet the SQL tab in the PHPMyAdmin
  • Enter the following script in to the SQL text box.
.
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
  
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
  • Modify the SQL query according to your table names in your database. The tables are wp_term_taxonomy, wp_term_relationships, wp_terms, wp_postmeta, wp_posts
  • Once the modification is done, click on the Go button to run the SQL query.
  • Once the SQL query is executed, you can check that all your products are deleted
  • Further read

    How to bulk delete woocommerce media?
    How to bulk delete woocommerce products using WordPress plugin?


    – Article ends here –

    If you have any questions, please feel free to share your questions or comments on the comment box below.

    Share this:
    We will be happy to hear your thoughts

    Leave a reply

    Troubleshootyourself
    Logo