• Is it possible to bulk delete orders via CLI using the wp wc shop_order delete command and adding a status flag (ex. status = canceled)? I tried using the --help flag, but that didn’t give me anything of substance.

    If this isn’t possible, can we please implement it? The best use case is 50k+ orders in the DB (my exact scenario) spanning over 3+ years and wanting to delete over 10k of them in one try rather than doing a page at a time and/or installing a plugin (mostly paid options) to do it.

Viewing 1 replies (of 1 total)
  • Saif

    (@babylon1999)

    Hello @elsqrd,

    Thank you for reaching out!

    There’s no status parameter for the delete command per this doc: https://github.com/woocommerce/woocommerce/wiki/WC-CLI-Commands#wc-shop_order

    If you haven’t migrated to HPOS, I guess you can use wp post delete and add the necessary parameters for order post_type.

    An easier route, in my opinion, is just using the data retention setting by navigating to WooCommerce > Settings > Account and Privacy. Then set an interval for how often these orders should be deleted.

    That’s it, the orders will be deleted regularly to the value you entered. If you want to speed up the process for the first time, you can install WP-Crontrol and run the woocommerce_cleanup_personal_data event manually once.

    NOTE: There’s no way to retrieve the data deleted by the data retention settings, so please make sure to have a reliable backup of your site before proceeding. Most hosting companies have this included in the subscription, but you could also consider using a service like Jetpack.

    Please let us know how it goes!

Viewing 1 replies (of 1 total)

The topic ‘Bulk Delete Orders via CLI’ is closed to new replies.