Delete all orders from Ucommerce

A while ago I blogged about [how to delete test orders and baskets from Ucommerce](https://thesitedoctor.co.uk/blog/deleting-test-orders-and-baskets-from-ucommerce/) and [Delete all products and orders from Ucommerce](https://thesitedoctor.co.uk/blog/delete-all-products-and-orders-from-ucommerce/) which I frequently use. As I often want to only clear out the orders as well so I thought it worth popping together a quick script to delete only the orders. This works on Ucommerce v9 and should work for older versions too but I've not tested it. BEGIN TRAN DELETE FROM uCommerce_OrderLineDiscountRelation DELETE FROM uCommerce_ShipmentDiscountRelation DELETE FROM uCommerce_Discount UPDATE uCommerce_OrderLine SET ShipmentId = NULL UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL DELETE FROM uCommerce_Shipment DELETE FROM uCommerce_OrderAddress DELETE FROM uCommerce_OrderProperty DELETE FROM uCommerce_OrderLine DELETE FROM uCommerce_PaymentProperty DELETE FROM uCommerce_Payment DELETE FROM uCommerce_OrderStatusAudit DELETE FROM uCommerce_PurchaseOrder DELETE FROM uCommerce_Address -- NOTE: Only needed if you use our Stripe package -- DELETE FROM uCommerce_StripeCustomer SELECT * FROM uCommerce_PurchaseOrder o ROLLBACK TRAN -- When happy it works, uncomment this line and comment out the ROLLBACK -- COMMIT TRAN

Subscribe to TSD

Don’t miss out on the latest posts. Sign up now to get access to the library of members-only posts.
jamie@example.com
Subscribe