Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @sevun,

    Thank you for reaching out.

    I understand you would like to delete customers with no orders using SQL. While we do not provide custom coding assistance, I’d be happy to help you out with this one.

    Please note that this is a very sensitive operation and I highly recommend trying the code at your own risk. Before that, also be sure to have a full site backup to avoid messing with your live store.

    DELETE FROM wp_users WHERE ID NOT IN (SELECT post_author FROM wp_posts WHERE post_type = 'shop_order');

    This command will delete all users that have not placed any orders. Please replace ‘wp_’ with your table prefix if it’s different.

    Should the code not function, I recommend running the exact question you’re asking, along with the code provided, through an AI platform like ChatGPT for recommendations.

    I hope this helps.

    Thread Starter sevun

    (@sevun)

    Hi,

    Thank you for your assistance

    I asked Chatgpt to before but didn’t work

    I tried your code and it deletes all user as well.

    Then I have an other issue. When you delete users (wp_users) it seems they remains as customer (Woo>Clients). In which table are clients (woo)?

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @sevun

    I tried your code and it deletes all user as well.

    That’s great to hear.

    When you delete users (wp_users) it seems they remains as customer (Woo>Clients). In which table are clients (woo)?

    Did you clear the transient cache in woocommerce>status>tools? However, you can follow the steps shared here: https://github.com/woocommerce/woocommerce/issues/26054#issuecomment-826048725

    If you’ve SSH access, then you can run this command to delete all WooCommerce users:

    wp user list –field=ID –role=customer | xargs wp user delete –yes

    Keep in mind that this command will delete only customers; all of the data concerning their orders has remained intact.

    I hope this helps! Please let us know how it goes or if you need further assistance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I delete customers with no orders (SQL)?’ is closed to new replies.