• Resolved extremist87

    (@extremist87)


    what is the cleanest way to remove all customers and orders from the woocommerce system and setup new order numbering?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @extremist87

    Thanks for reaching out!

    I understand that you would like to delete all customers and orders on your site to start a new order numbering system, correct?

    I did some research and found these articles could be a good starting point:

    Hope this helps!

    Plugin Support Shameem a11n

    (@shameemreza)

    Hi @extremist87

    To remove all customers and orders from your WooCommerce system, you can use a plugin called “Advanced Database Cleaner“. This plugin will allow you to clean up your database by removing any unwanted data, including customers and orders.

    Once you have installed and activated the plugin, you can navigate to the “Clean-up” tab and select the “WooCommerce” option. From there, you can select the data you want to remove, such as customer and order data.

    Regarding setting up new order numbering, you can use a plugin called “Custom Order Numbers for WooCommerce“. This plugin will allow you to customize your order numbers to your liking, including adding prefixes or suffixes.

    Once you have installed and activated the plugin, you can navigate to the “Custom Order Numbers” tab and configure the settings to your preference.

    Additionally, if you are tech-savvy, you can follow these guides to remove WooCommerce Orders and user-related data:

    I hope this helps! Thanks!

    Hello,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

    Thanks.

    TechMan

    (@techman)

    There is no WooCommerce option in Cleanup tab of Advanced Database Cleaner.

    anastas10s

    (@anastas10s)

    Hi there @techman ??

    There is no WooCommerce option in Cleanup tab of Advanced Database Cleaner.

    I’d recommend reaching out to the Advanced Database Cleaner plugin support, about this, which can be accessed via this page: https://www.ads-software.com/support/plugin/advanced-database-cleaner/

    As an alternative, feel free to check out WP Reset.?With it you can quickly reset the site’s database to the default installation values without modifying any files. It deletes all customizations and content, or just chosen parts like theme settings.

    I hope this is helpful! Please let us know if you have any further questions or concerns.

    WordPress document https://developer.www.ads-software.com/plugins/plugin-basics/uninstall-methods/ said When your plugin is uninstalled, you’ll want to clear out any plugin options and/or settings specific to the plugin, and/or other database entities such as tables.

    So, it should be this plugin’s task to delete these data for us. Not just leave a lot of junk and let the other plugin did it.

    Hey, @okvee!

    So, it should be this plugin’s task to delete these data for us. Not just leave a lot of junk and let the other plugin did it.

    Thanks for your input!

    As we understand the original ask on this thread was about removing customers and resetting order numbers, not about deleting the plugin. ??

    If you are facing any issues deleting the plugin or with something else, would you mind opening up a new thread for this so that we can keep things organized and offer more personalized support for you? We’ll be happy to help you out with this over there!

    Have a wonderful day!

    I have spent a bit of time working the following out.

    My objective was to duplicate an existing WooCommerce site and retain products only.

    This meant I wanted to delete: Orders, Customers, Analytics data, Product Reviews etc.

    Please note the query below deletes all comments, so BE WARNED.

    Obviously backup database and test in a development environment.

    Please note: When working on my local setup using MAMP phpMyAdmin, I was getting a timeout error on Step 3: so what i did was create a new database on live hosting and imported the live into that, so I had a duplicate I could work on. Ran all the queries there, then exported and imported into my local from there.

    
    -- Step 1 - Delete orders
    
    -- Disable foreign key checks temporarily
    SET FOREIGN_KEY_CHECKS = 0;
    -- Delete order items
    DELETE FROM wp_woocommerce_order_items WHERE order_id IN (SELECT ID FROM wp_posts WHERE post_type = 'shop_order');
    -- Delete order item meta
    DELETE FROM wp_woocommerce_order_itemmeta WHERE order_item_id IN (SELECT order_item_id FROM wp_woocommerce_order_items WHERE order_id IN (SELECT ID FROM wp_posts WHERE post_type = 'shop_order'));
    -- Delete order notes
    DELETE FROM wp_comments WHERE comment_post_ID IN (SELECT ID FROM wp_posts WHERE post_type = 'shop_order');
    -- Delete order note meta
    DELETE FROM wp_commentmeta WHERE comment_id IN (SELECT comment_ID FROM wp_comments WHERE comment_post_ID IN (SELECT ID FROM wp_posts WHERE post_type = 'shop_order'));
    -- Delete order data (post meta)
    DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'shop_order');
    -- Delete orders
    DELETE FROM wp_posts WHERE post_type = 'shop_order';
    -- Enable foreign key checks
    SET FOREIGN_KEY_CHECKS = 1;
    
    
    -- Step 2: Delete analytics data
    
    -- Disable foreign key checks temporarily
    SET FOREIGN_KEY_CHECKS = 0;
    -- Delete data from order stats table
    DELETE FROM wp_wc_order_stats;
    -- Delete data from order product lookup table
    DELETE FROM wp_wc_order_product_lookup;
    -- Delete data from product meta lookup table
    DELETE FROM wp_wc_product_meta_lookup;
    -- Enable foreign key checks
    SET FOREIGN_KEY_CHECKS = 1;
    
    
    -- Step 3: Remove users with role customer
    
    -- Create a temporary table to store user IDs of customers
    CREATE TEMPORARY TABLE temp_customers AS
    SELECT DISTINCT user_id
    FROM wp_usermeta
    WHERE meta_key LIKE '%capabilities%' AND meta_value LIKE '%customer%';
    -- Disable foreign key checks temporarily
    SET FOREIGN_KEY_CHECKS = 0;
    -- Delete user meta data
    DELETE FROM wp_usermeta
    WHERE user_id IN (SELECT user_id FROM temp_customers);
    -- Delete users
    DELETE FROM wp_users
    WHERE ID IN (SELECT user_id FROM temp_customers);
    -- Enable foreign key checks
    SET FOREIGN_KEY_CHECKS = 1;
    -- Drop the temporary table
    DROP TEMPORARY TABLE IF EXISTS temp_customers;
    
    
    -- Step 4: Delete all comments
    
    -- Disable foreign key checks temporarily
    SET FOREIGN_KEY_CHECKS = 0;
    -- Delete all comments
    DELETE FROM wp_comments;
    -- Enable foreign key checks
    SET FOREIGN_KEY_CHECKS = 1;
    
    
    -- Step 5: Delete all customer data from WooCommerce > Customers - AKA: wp_wc_customer_lookup
    
    -- Disable foreign key checks temporarily
    SET FOREIGN_KEY_CHECKS = 0;
    -- Delete all entries from wp_wc_customer_lookup
    DELETE FROM wp_wc_customer_lookup;
    -- Enable foreign key checks
    SET FOREIGN_KEY_CHECKS = 1;
    
    
    -- Step 6: Clear both transient caches + customer sessions + analytics cache : WooCommerce > Status > Tools
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘delete all orders and customers from system’ is closed to new replies.