Tuesday, May 21, 2024

WooCommerce Perform Bulk Operations from the Database

 SQL queries to perform following bulk operations from the database:


Bulk Delete All Orders

DELETE FROM wp_woocommerce_order_itemmeta;

DELETE FROM wp_woocommerce_order_items;

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';

Bulk Delete All Products

DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type IN ( 'product', 'product_variation' ));

DELETE FROM wp_posts WHERE post_type IN ( 'product', 'product_variation' );



Bulk Delete All Trashed Products

DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'product' AND post_status = 'trash' );

DELETE FROM wp_posts WHERE post_type = 'product' AND post_status = 'trash';


Bulk Delete All Order Notes

DELETE FROM wp_commentmeta WHERE comment_id IN ( SELECT ID FROM wp_comments WHERE comment_type = 'order_note' );

DELETE FROM wp_comments WHERE comment_type = 'order_note';




No comments:

Post a Comment