Select version
v7.1 v7.0 v6.8 v6.7 v6.6 v6 v5 v4 v3 v2

Deleting Purchase Orders and Baskets from the Database in uCommerce

One thing you might want to do before putting a new uCommerce solution into a production environment is remove any test baskets and orders you might have placed during development. The schema gets a little complicated with the rich functionality found in the uCommerce Transaction Foundation requiring the objects to be removed in a certain order.

image

Here’s how you go about deleting them.

*** WARNING! HERE BE DRAGONS! ***

Please be aware that running the following script will remove any baskets and orders found in the system with no way to get them back unless you have a database backup handy.

    
    
    --DELETE PURCHASEORDERS AND ASSOCIATED DATA
    BEGIN TRAN
     
    -- Delete reviews
    DELETE FROM uCommerce_ProductReviewComment
    DELETE FROM uCommerce_ProductReview
     
    -- Delete discounts
    DELETE FROM uCommerce_OrderLineDiscountRelation
    DELETE FROM uCommerce_Discount
     
    -- Remove shipment <-> order line link
    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
    DELETE FROM uCommerce_Customer
    --COMMIT
    
    

As an added precaution I uncommented the commit statement in case you were wondering why the data isn’t being deleted :)

uCommerce Aps - Studsgade 29B - 8000 Aarhus C - Denmark
Phone +45 61 799 997 - Email [email protected] uCommerce logo