Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Mark Slade 48 posts 109 karma points
    Jul 08, 2013 @ 21:23
    Mark Slade
    0

    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

     

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Jul 09, 2013 @ 13:18
    Nickolaj Lundgreen
    0

    I would guess that you need to set the OrderId property on the discount object :)

Please Sign in or register to post replies

Write your reply to:

Draft