Search code examples
woocommercewoocommerce-rest-api

Deleting order Woocommerce orders via API


I want to programmatically delete old orders in Woocommerce, to try to assist database performance, so I am considering running this via the API documented below. The documentation doesn't detail exactly what is deleted - is it just the order, and its metadata? Does it delete the notes of an order for example?

https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-an-order


Solution

  • /wp-json/wc/v3/orders/ The above HTTP request will delete the order and its metadata, you will have to send a different HTTP request to delete its notes as below.

    /wp-json/wc/v3/orders//notes/<note_id>

    https://woocommerce.github.io/woocommerce-rest-api-docs/?php#delete-an-order-note