Delete all orders of a customer

Use this procedure to delete all of the orders of a specific customer.
Perform the following:

  1. Get the orders manager.
    Get an instance of the OrdersManager object.
  2. Get the customer.
    Call the GetCustomer method of the orders manager and pass the customer's unique identifier.
  3. Get the customer's orders.
    Call GetOrders method of the orders manager and filter the resulting querable collection by the customer Id.
  4. Delete the orders of the customer.
    Call DeleteOrder method of the orders manager.
  5. Get the addresses of the customer.
    Call GetCustomerAddresses method of the orders manager and filter the resulting collection by the customer Id.
  6. Delete the addresses of the customer
    Call DeleteCustomerAddress method of the orders manager.
  7. Get the customer statistics
    Call GetCustomerStatistics method of the orders manager.
  8. Delete the customer statistics
    Call DeleteCustomerStatistics method of the orders manager.
  9. Get the customer money.
    Call GetCustomerMoneys method of the orders manager.
  10. Delete the customer money
    Call DeleteCustomerMoney method of the orders manager.
  11. Save the changes to the manager.

Use the following code sample:

As a result all orders made by a specific customer are deleted.

For more information on deleting a customer see: For developers: Delete customers

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?