how to delete completed orders in woocommerce using a my sql query

后端 未结 5 839
慢半拍i
慢半拍i 2021-01-03 08:02

I want to delete completed all orders in woocommerce by using a single my sql query. Because, I\'m having a problem with my WordPress Dashboard

5条回答
  •  走了就别回头了
    2021-01-03 08:25

    To delete orders with completed status, you should only use the following code.

    UPDATE wp_posts 
    SET post_status = 'trash' 
    WHERE post_type = 'shop_order'
    AND post_status = 'wc-completed'
    

    This code does not completely eliminate the system or base of Order data, send it to the trash.


    Do you want to permanently delete orders ?, you must go to:

    Woocommerce > Orders > Trash and click Empty Trash.


    If you want to eliminate other orders, you should only know the different status that exists in Woocommerce:

    1. wc-completed
    2. wc-pending
    3. wc-processing
    4. wc-on-hold
    5. wc-cancelled
    6. wc-refunded
    7. wc-failed

    And you are specifying them inside the clause IN ('status')

    UPDATE wp_posts 
    SET post_status = 'trash' 
    WHERE post_type = 'shop_order'
    AND post_status IN ('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-cancelled', 'wc-refunded', 'wc-failed')
    

提交回复
热议问题