Discounts

How can i manpulate many discounts to show them on aspx page?

( we are using commerce server 2007, SQL 2005, VS 2005)

[130 byte] By [Hi_4_All] at [2007-12-27]
# 1

Hi,

Can you be more specific about your problem?

--Sachin Saxena

SachinSaxena at 2007-9-3 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 2
ok, i want to display all the all discounts for my partners
Hi_4_All at 2007-9-3 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 3

You could consider using the runtime discount filter:

http://msdn2.microsoft.com/en-us/library/microsoft.commerceserver.runtime.marketing.aspx

Here's a code sample:

DiscountItemCollection allDiscounts = DiscountItemCollection.CreateFromCache("Discounts");
DiscountCriteriaFilter filter = new DiscountCriteriaFilter();
DiscountItemCollection applicableDiscounts = allDiscounts.ApplyProductFilter(filter, catalog, product);

foreach(DiscountItem item in applicableDiscounts)
{

//your logic here
}

Try tweaking the DiscountCriteriaFilter (documentation provided on the link above) to get what you want to display. You probably want to avoid showing discounts that require a coupon code.

JosephJohnson at 2007-9-3 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 4
thanks joseph
Hi_4_All at 2007-9-3 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 5

I try Your code and see in allDiscounts all my discounts.

When I apply ApplyProductFilter or ApplyCategoryFilter it always returns zero items. Still I set productid or category id with discount.

Esp. for product id wich in my bascet gets the correct discount.

I use virtual catalogs and set the discount on the virtual catalog for the category the product belongs to.

Any idea why I not get any results at all?

Regards Johan

JohanS?rlin at 2007-9-3 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 6

Johan,

What properties are you setting on the DiscountCriteriaFilter? This is probably the reason you're not getting any records.

Here's the documentation on it:

http://msdn2.microsoft.com/en-us/library/microsoft.commerceserver.runtime.marketing.discountcriteriafilter.aspx

I don't know what the default setting is for the five member properties, but you'll probably need to set some of them to true to populate the collection.

JosephJohnson at 2007-9-3 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 7

Using virtual catalogs. Tried diffrent combinations on filter flags. Still no with result.

See code below

void MyTest()
{
DiscountItemCollection allDiscounts = DiscountItemCollection.CreateFromCache("Discounts");
DiscountCriteriaFilter filter = new DiscountCriteriaFilter();
filter.FilterOnAward = false;
filter.FilterOnCondition = false;
filter.IncludeDiscountsWithEligibilityRequirements = false;
filter.IncludeDiscountsWithPromoCodes = false;
filter.IncludeInactiveDiscounts = false;
DiscountItemCollection applicableDiscounts = allDiscounts.ApplyProductFilter(filter, "GB-Catalog", "TG_TSHIRT(ScaniaBaseCatalog)");

foreach (DiscountItem item in applicableDiscounts)
{
Response.Write(item.ToString());
//your logic here
}
}

JohanS?rlin at 2007-9-3 > top of Msdn Tech,Commerce Server,Commerce Server 2007...