I'm trying to apply a discount on an order and this is my code:-
Dim iDisc as Integer = 10
Dim oBasket = TransactionLibrary.GetBasket(True).PurchaseOrder
Dim dOrderTotal As Decimal = oBasket.OrderTotal.Value
Dim dDiscAmount As Decimal = dOrderTotal / 100 * iDisc
Dim oDisc As Discount = New Discount
oDisc.AmountOffTotal = dDiscAmount
oBasket.Discounts.Add(oDisc)
oBasket.Save()
TransactionLibrary.ExecuteBasketPipeline()
When it hits the line oBasket.Save() is get the following:-
Cannot insert the value NULL into column 'OrderId', table 'DMG.dbo.uCommerce_Discount'; column does not allow nulls. INSERT fails. The statement has been terminated.
Help with discounts
Hi Guys,
I'm trying to apply a discount on an order and this is my code:-
Dim iDisc as Integer = 10
Dim oBasket = TransactionLibrary.GetBasket(True).PurchaseOrder
Dim dOrderTotal As Decimal = oBasket.OrderTotal.Value
Dim dDiscAmount As Decimal = dOrderTotal / 100 * iDisc
Dim oDisc As Discount = New Discount
oDisc.AmountOffTotal = dDiscAmount
oBasket.Discounts.Add(oDisc)
oBasket.Save()
TransactionLibrary.ExecuteBasketPipeline()
When it hits the line oBasket.Save() is get the following:-
Cannot insert the value NULL into column 'OrderId', table 'DMG.dbo.uCommerce_Discount'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Any clue? Am I applying the discount correctly?
Sorry for being a Newbie!
Mark
I would guess that you need to set the OrderId property on the discount object :)
is working on a reply...