Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

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
    ROLLBACK
    
    

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