Discounts in basket
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Discounts in basket

 
Post new topic   Reply to topic    Windows Server Forum Index -> Commerce Server
Author Message
adam
Guest





Posted: Thu Sep 29, 2005 8:51 pm    Post subject: Discounts in basket Reply with quote

Hi there i know this has been covered before, but we're still not quite
getting there.

We found the following post
http://blogs.msdn.com/yuxiangxu/archive/2004/06/29/169123.aspx on Andy
Xu's blog. However we tried to do a quick code translation from VB.NET
to C# - and we may have got this wrong. But the code does not work as
expected.

Taking the code in Andy's blog post, we have come up with the following
code, and when run we get an invalid cast exception. Any ideas please?:

OrderForm cartOrderForm = basket.OrderForms[0];
ISimpleList discountApplicationRecords;
int campaignItemID;
decimal discountAmount;

//assume basket pipeline is exeecuted and we get the orderForm in
variable cartOrderForm

discountAmount = 0;
foreach(LineItem item in cartOrderForm.LineItems)
{

if(!(item["_itemlevel_discounts_applied"].Equals(System.DBNull.Value)))
{
discountApplicationRecords =
(ISimpleList)item["_itemlevel_discounts_applied"];

foreach(System.Collections.IDictionary discountApplicationRecord in
discountApplicationRecords)
{
campaignItemID = (int)discountApplicationRecord["discount_id"];

if(campaignItemID == 1)
{
discountAmount +=
(decimal)discountApplicationRecord["cy_discount_amount"];
}
}
}
}

return discountAmount;
Back to top
Nihit Kaul [MSFT]
Guest





Posted: Fri Sep 30, 2005 8:50 pm    Post subject: RE: Discounts in basket Reply with quote

What line are you getting the case exception on?

Thanks,

Nihit Kaul[MSFT]
Commerce Server
http://blogs.msdn.com/nihitk

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
From: "adam" <adam.stewart@framfab.com>
Newsgroups: microsoft.public.commerceserver.general
Subject: Discounts in basket
Date: 29 Sep 2005 10:29:26 -0700
Organization: http://groups.google.com
Lines: 45
Message-ID: <1128014966.689065.133700@g47g2000cwa.googlegroups.com>
NNTP-Posting-Host: 194.201.25.93
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1128014972 29573 127.0.0.1 (29 Sep 2005
17:29:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 29 Sep 2005 17:29:32 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET
CLR 1.1.4322; .NET CLR 1.0.3705),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: g47g2000cwa.googlegroups.com; posting-host=194.201.25.93;
posting-account=kf8PqA0AAABDDcmuKIAt7Lb0CIx3Qjd_
Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!ne
wsfeed1.ip.tiscali.net!news.glorb.com!postnews.google.com!g47g2000cwa.google
groups.com!not-for-mail
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.commerceserver.general:3608
X-Tomcat-NG: microsoft.public.commerceserver.general

Hi there i know this has been covered before, but we're still not quite
getting there.

We found the following post
http://blogs.msdn.com/yuxiangxu/archive/2004/06/29/169123.aspx on Andy
Xu's blog. However we tried to do a quick code translation from VB.NET
to C# - and we may have got this wrong. But the code does not work as
expected.

Taking the code in Andy's blog post, we have come up with the following
code, and when run we get an invalid cast exception. Any ideas please?:

OrderForm cartOrderForm = basket.OrderForms[0];
ISimpleList discountApplicationRecords;
int campaignItemID;
decimal discountAmount;

//assume basket pipeline is exeecuted and we get the orderForm in
variable cartOrderForm

discountAmount = 0;
foreach(LineItem item in cartOrderForm.LineItems)
{

if(!(item["_itemlevel_discounts_applied"].Equals(System.DBNull.Value)))
{
discountApplicationRecords =
(ISimpleList)item["_itemlevel_discounts_applied"];

foreach(System.Collections.IDictionary discountApplicationRecord in
discountApplicationRecords)
{
campaignItemID = (int)discountApplicationRecord["discount_id"];

if(campaignItemID == 1)
{
discountAmount +=
(decimal)discountApplicationRecord["cy_discount_amount"];
}
}
}
}

return discountAmount;
Back to top
adam
Guest





Posted: Sat Oct 01, 2005 12:50 pm    Post subject: Re: Discounts in basket Reply with quote

Sorry, i should have said where this error was happening !!

its the cast to IDictionary of the foreach part where the cast
exception occurs.

TIA

Adam

Nihit Kaul [MSFT] wrote:
Quote:
What line are you getting the case exception on?

Thanks,

Nihit Kaul[MSFT]
Commerce Server
http://blogs.msdn.com/nihitk

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
From: "adam" <adam.stewart@framfab.com
Newsgroups: microsoft.public.commerceserver.general
Subject: Discounts in basket
Date: 29 Sep 2005 10:29:26 -0700
Organization: http://groups.google.com
Lines: 45
Message-ID: <1128014966.689065.133700@g47g2000cwa.googlegroups.com
NNTP-Posting-Host: 194.201.25.93
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1128014972 29573 127.0.0.1 (29 Sep 2005
17:29:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 29 Sep 2005 17:29:32 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET
CLR 1.1.4322; .NET CLR 1.0.3705),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: g47g2000cwa.googlegroups.com; posting-host=194.201.25.93;
posting-account=kf8PqA0AAABDDcmuKIAt7Lb0CIx3Qjd_
Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!ne
wsfeed1.ip.tiscali.net!news.glorb.com!postnews.google.com!g47g2000cwa.google
groups.com!not-for-mail
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.commerceserver.general:3608
X-Tomcat-NG: microsoft.public.commerceserver.general

Hi there i know this has been covered before, but we're still not quite
getting there.

We found the following post
http://blogs.msdn.com/yuxiangxu/archive/2004/06/29/169123.aspx on Andy
Xu's blog. However we tried to do a quick code translation from VB.NET
to C# - and we may have got this wrong. But the code does not work as
expected.

Taking the code in Andy's blog post, we have come up with the following
code, and when run we get an invalid cast exception. Any ideas please?:

OrderForm cartOrderForm = basket.OrderForms[0];
ISimpleList discountApplicationRecords;
int campaignItemID;
decimal discountAmount;

//assume basket pipeline is exeecuted and we get the orderForm in
variable cartOrderForm

discountAmount = 0;
foreach(LineItem item in cartOrderForm.LineItems)
{

if(!(item["_itemlevel_discounts_applied"].Equals(System.DBNull.Value)))
{
discountApplicationRecords =
(ISimpleList)item["_itemlevel_discounts_applied"];

foreach(System.Collections.IDictionary discountApplicationRecord in
discountApplicationRecords)
{
campaignItemID = (int)discountApplicationRecord["discount_id"];

if(campaignItemID == 1)
{
discountAmount +=
(decimal)discountApplicationRecord["cy_discount_amount"];
}
}
}
}

return discountAmount;
Back to top
adam
Guest





Posted: Tue Oct 11, 2005 4:51 pm    Post subject: Re: Discounts in basket Reply with quote

Anyone? this is getting to be quite important now?!

Please.
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Commerce Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB