Getting the Discount object

Hi All,

I have this following code:

foreach (LineItem lineIteminthis.BasketHelper.GetAllLineItems())

{

foreach (DiscountApplicationRecord discountApplicationRecordin lineItem.ItemLevelDiscountsApplied)

{

Discount disc = (Discount)discountApplicationRecord.DiscountId; (?)

string condition = discount.Condition.ConditionExpression.ToString();

string award = discount.AwardExpression.ToString();

}

}

I get all the list of line items and the available item level discount. I need to get the Discount object based on the available discountApplicationRecord .DiscountId. How can i get the Discount object?

I need this in order to retrieve the free items belong to the discount and add it to the cart.

Please respond to this code ASAP.

Nazim

[1764 byte] By [Nazim71177] at [2008-1-8]
# 1

By Discount Object I think you mean Microsoft.CommerceServer.Marketing.Discount.

To get this object, you need to create an instance of Microsoft.CommerceServer.Marketing.MarketingContext (see http://msdn2.microsoft.com/en-us/library/microsoft.commerceserver.marketing.marketingcontext.aspx). You should create a singleton for this object since it is a heavyweight object. Then you can use the MarketingContext.CampaignItems.GetCampaignItem(int discountId) method to retreive the discount.

Hope that helps,

madhur

madhur-MSFT at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...