Hi DW,
I have an issue with deleting an order by the api as we got this error:
The DELETE statement conflicted with the REFERENCE constraint "DW_FK_EcomOrderLines_EcomOrders"
If I look in the code we have this function:
Public Shared Sub Delete(id As String) Dim args As New Notifications.Ecommerce.Order.BeforeDeleteArgs(id) NotificationManager.Notify(Notifications.Ecommerce.Order.BeforeDelete, args) If args.StopExecution Then Exit Sub Database.ExecuteNonQuery(CommandBuilder.Create("UPDATE R SET R.[RecurringOrderEndDate] = GETDATE() FROM [EcomRecurringOrder] R LEFT JOIN [EcomOrders] O ON R.RecurringOrderId = O.OrderRecurringOrderId WHERE (O.[OrderID] = {0} AND (R.[RecurringOrderStartDate] IS NULL OR R.[RecurringOrderBaseOrderID] = {0}))", id)) Dim query As String = "DELETE FROM EcomOrders WHERE OrderID = '" & id & "'" Database.ExecuteNonQuery(query) query = "DELETE FROM EcomOrderLines WHERE OrderLineOrderID = '" & id & "'" Database.ExecuteNonQuery(query) query = "DELETE FROM EcomOrderDebuggingInfo WHERE OrderDebuggingInfoOrderID = '" & id & "'" Database.ExecuteNonQuery(query) query = " update AccessUser set AccessUserCartID= '' where AccessUserCartID='" & id & "'" Database.ExecuteNonQuery(query) NotificationManager.Notify(Notifications.Ecommerce.Order.AfterDelete, New Notifications.Ecommerce.Order.AfterDeleteArgs(id)) End Sub
I would mean that "DELETE FROM EcomOrders ..." should be after deleting orderlines and debug info to avoid with conflict?
Best regards, Anders