Skip to content

Instantly share code, notes, and snippets.

@mPanasiewicz
Last active October 17, 2023 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mPanasiewicz/5127b23b214597772d4f3ae9fc8c6fbd to your computer and use it in GitHub Desktop.
Save mPanasiewicz/5127b23b214597772d4f3ae9fc8c6fbd to your computer and use it in GitHub Desktop.
Woocommerce deleton SQLs
# This query deletes all users which have been created through woocommerce sign up form
DELETE from wp_users where wp_users.ID not in (
SELECT meta_value FROM wp_postmeta WHERE meta_key = '%_customer_user'
) AND wp_users.ID not in (select distinct(post_author) from wp_posts);
# This query deletes all woocommerce orders
# [IMPORTANT] QUERY ORDER MATTERS [IMPORTANT]
DELETE FROM wp_woocommerce_order_itemmeta;
DELETE FROM wp_woocommerce_order_items;
DELETE FROM wp_commentmeta WHERE meta_id IN ( SELECT comment_id FROM wp_comments WHERE comment_type = 'order_note' );
DELETE FROM wp_comments WHERE comment_type = 'order_note';
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_order' );
DELETE FROM wp_posts WHERE post_type = 'shop_order';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment