Handige WooCommerce queries

Soms wil je wel eens snel alle WooCommerce orders of producten verwijderen. Je kunt onderstaande database queries gebruiken om het proces te versnellen.

Alle orders verwijderen

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 tmp4b0cb3_posts WHERE post_type = 'shop_order' );
DELETE FROM tmp4b0cb3_posts WHERE post_type = 'shop_order';

Alle producten verwijderen

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

Alle prullenbak producten verwijderen

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

Alle coupons verwijderen

DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM tmp4b0cb3_posts WHERE post_type = 'shop_coupon' );
DELETE FROM tmp4b0cb3_posts WHERE post_type = 'shop_coupon';

Alle order notities verwijderen

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