7. May 2023 |

wp cli delete orders older than…

Overview of WooCommerce CLI can be found here and examples here.

Delete shop order by ID, need to add user id that has permissions to delete orders.

wp wc shop_order delete <id> --user=1

Delete orders where date is older than…

for id in $(wp db query "SELECT id FROM wp_posts WHERE post_date < '2021-01-01' AND post_type='shop_order'" --skip-column-names); do wp wc shop_order delete $id --user=1 --force=1; done

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.