|
Home > Archive > Content Selection Framework > January 2005 > 'Gift With Purchase' problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
'Gift With Purchase' problem
|
|
| agindian 2005-01-12, 5:53 pm |
| HI,
I am trying to convert the Gift with Purchase vb code to c# code.
====================
Function getFreeGifts(mscsOrderGrp)
'Get a list of the discounts the shopper qualifies for, but
for which there is
'no award item (orderform.[_qualifying_discounts])
'But the list may also contain NON GWP DISCOUNTS. So, GWP
discounts have to be separated from others, and returned.
Dim oOrderForm, oQualifyingDiscounts, oQualifyingDiscount,
expressionStore
Dim freeDiscount, allDiscounts, freeItems, tempExprID
set freeItems = Server.CreateObject("Commerce.SimpleList")
set oOrderForm =
mscsOrderGrp.Value(ORDERFORMS).Value("default")
'If the "_qualifying_discounts" key does not exist, then just
proceed further, and return the empty simple list
on error resume next
set oQualifyingDiscounts = oOrderForm.[_qualifying_discounts]
if Err.number = 0 then
'The expressionStore object has to be initialised
before calling this function
Set expressionStore =
Application("MSCSExpressionStore")
Set allDiscounts = oOrderForm.[_discounts]
for each oQualifyingDiscount in
oQualifyingDiscounts
'"item_id" key refers to the campaign
item ID (database::: CAMPAIGN_ITEM.i_campitem_id)
Set freeDiscount =
allDiscounts.Search("item_id", oQualifyingDiscount)
'Only discounts which are ITEMLEVEL
(order_level=0), % OFF (offer_type=2)
' and 100% OFF (offer_value=100) are
chosen
if(freeDiscount.Fields("order_level")=0 and
freeDiscount.Fields("offer_type")=2 and
freeDiscount.Fields("offer_value")=100) then
'Assuming that the
EXPRESSION NAME = PRODUCT ID
tempExprID =
freeDiscount.Fields("award_expr")
freeItems.Add(expressionStore.getExprName(tempExprID))
end if
next
End if
Set getFreeGifts = freeItems
End Function
====================
When I run the code, I am not able to get the lists
oOrderForm.[_qualifying_discounts] and oOrderForm.[_discounts]. What are
the list objects in each of these lists? Does
oOrderForm.[_qualifying_discounts] return a list of strings or is it a
list of objects?
what abt oOrderForm.[_discounts]..?
And finally, is it possible that the value for _qualifying_discounts is
not written (even when there are eligible discounts) inside the basket
pipeline , orderdiscount component?
Thanks in Advance..
| |
| Zoe Hart [MVP] 2005-01-13, 7:47 am |
| Here's some C# I've used related to Gift With Purchase. The "as" operator is
just one way of doing it. The important part is orderForm.Dictionary...
SimpleList qualDiscounts = orderForm.Dictionary["_qualifying_discounts"] as
SimpleList;
if (qualDiscounts != null)
{
ContentList allDiscounts = orderForm.Dictionary["_discounts"] as
ContentList;
foreach(int discountID in qualDiscounts)
{
RowCollection discountConfig = allDiscounts.Search("item_id",
discountID);
discountConfig.MoveFirst;
// You can now access the discount information with the following
syntax:
// discountConfig.Fields["order_level"]
}
}
Hope that helps.
Zoe
"agindian" <asdghas@yahoo.com> wrote in message
news:0348a1417397935b670fe22e1e5d252a@lo
calhost.talkaboutsoftware.com...
> HI,
>
> I am trying to convert the Gift with Purchase vb code to c# code.
>
> ====================
> Function getFreeGifts(mscsOrderGrp)
> 'Get a list of the discounts the shopper qualifies for, but
> for which there is
> 'no award item (orderform.[_qualifying_discounts])
> 'But the list may also contain NON GWP DISCOUNTS. So, GWP
> discounts have to be separated from others, and returned.
>
> Dim oOrderForm, oQualifyingDiscounts, oQualifyingDiscount,
> expressionStore
> Dim freeDiscount, allDiscounts, freeItems, tempExprID
> set freeItems = Server.CreateObject("Commerce.SimpleList")
> set oOrderForm =
> mscsOrderGrp.Value(ORDERFORMS).Value("default")
> 'If the "_qualifying_discounts" key does not exist, then just
> proceed further, and return the empty simple list
> on error resume next
> set oQualifyingDiscounts = oOrderForm.[_qualifying_discounts]
> if Err.number = 0 then
> 'The expressionStore object has to be initialised
> before calling this function
> Set expressionStore =
> Application("MSCSExpressionStore")
> Set allDiscounts = oOrderForm.[_discounts]
> for each oQualifyingDiscount in
> oQualifyingDiscounts
> '"item_id" key refers to the campaign
> item ID (database::: CAMPAIGN_ITEM.i_campitem_id)
> Set freeDiscount =
> allDiscounts.Search("item_id", oQualifyingDiscount)
> 'Only discounts which are ITEMLEVEL
> (order_level=0), % OFF (offer_type=2)
> ' and 100% OFF (offer_value=100) are
> chosen
>
> if(freeDiscount.Fields("order_level")=0 and
> freeDiscount.Fields("offer_type")=2 and
> freeDiscount.Fields("offer_value")=100) then
> 'Assuming that the
> EXPRESSION NAME = PRODUCT ID
> tempExprID =
> freeDiscount.Fields("award_expr")
>
> freeItems.Add(expressionStore.getExprName(tempExprID))
> end if
> next
> End if
>
> Set getFreeGifts = freeItems
>
> End Function
>
> ====================
>
> When I run the code, I am not able to get the lists
> oOrderForm.[_qualifying_discounts] and oOrderForm.[_discounts]. What are
> the list objects in each of these lists? Does
> oOrderForm.[_qualifying_discounts] return a list of strings or is it a
> list of objects?
> what abt oOrderForm.[_discounts]..?
>
> And finally, is it possible that the value for _qualifying_discounts is
> not written (even when there are eligible discounts) inside the basket
> pipeline , orderdiscount component?
>
> Thanks in Advance..
>
>
| |
| Sreeku_2002 2005-01-14, 5:50 pm |
| Hi,
Is _qualifying_discounts present in FP1.It doesnt appear in the values
written portion of order discount pipeline component.
Is there some other way of finding order level qualifying discounts for
the basket in FP1?
regards,
sreeku
| |
| David Messner [MSFT] 2005-01-18, 5:53 pm |
| Yes, the _qualifying_discounts key is written in both CS2002 and FP1 (only
when some discount met the condition part but for which there was nothing
to award to). This is documented, but it is indeed missing from the
"Values read written" in pipeline editor - we'll fix this.
You might also be looking for _orderlevel_discounts_detail, which is
documented.
Regards
-djm
--
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2005 Microsoft Corporation. All rights
reserved.
--------------------
From: "Sreeku_2002" <sreeku_2002@yahoo.com>
Newsgroups: microsoft.public.commerceserver.campaigns_csf
Subject: Re: 'Gift With Purchase' problem
Date: Fri, 14 Jan 2005 14:05:51 -0500
Organization: www.talkaboutsoftware.com
Message-ID:
< f601ef5be285efef0b51b94c1ccb5bfa@localho
st.talkaboutsoftware.com>
X-Newsreader: www.talkaboutsoftware.com
Content-Type: text/plain;
References:
< 0348a1417397935b670fe22e1e5d252a@localho
st.talkaboutsoftware.com>
<u2WVH$W#EHA.3820@TK2MSFTNGP11.phx.gbl>
X-Complaints-To: abuse@supernews.com
Lines: 11
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.s
ul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!s
n-xit-04!sn-xit-08!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
Xref: cpmsftngxa10.phx.gbl
microsoft.public.commerceserver.campaigns_csf:2992
X-Tomcat-NG: microsoft.public.commerceserver.campaigns_csf
Hi,
Is _qualifying_discounts present in FP1.It doesnt appear in the values
written portion of order discount pipeline component.
Is there some other way of finding order level qualifying discounts for
the basket in FP1?
regards,
sreeku
|
|
|
|
|