I implemented a commerce server application with discount and ad. campaign
of
type 'image' using the commerce server 2002 help file lab 1- 4 sessions.
The discount campaign is implemented for target group female contractor
for
product electrrical switch with SKU 6001.
In the default.aspx page in page load ,I wrote code for displaying ad.
and
discount
in the texts of the labels using following code:
In the Page_Load() method, add the following code:
// Create a targeting profile
CommerceContext ctx = CommerceContext.Current;
Profile userProfile = null;
bool isLoggedOn = ctx.AuthenticationInfo.IsAuthenticated();
if (isLoggedOn)
{
// Extract the user's profile for the Campaign system to
// decide if the user should be targeted for a given ad.
ProfileContext profContext = ctx.ProfileSystem;
string userId = ctx.AuthenticationInfo.AuthTicket.UserID;
userProfile = profContext.GetProfile(userId, "UserObject");
}
//check for the profile
// Get the AD
// Get a ContentSelector and set its properties
ContentSelector csoAd =
ctx.TargetingSystem.SelectionContexts["advertising"].GetSelector();
csoAd.TraceMode = true;
csoAd.ItemsRequested = 1;
if(null != userProfile)
{
csoAd.Profiles.Add("User", userProfile);
}
csoAd.Size = "Banner";
// Get some content using CS2002 Content Selection Framework
StringCollection adpayload = csoAd.GetContent();
foreach (string adItem in adpayload)
{
adLabel.Text = adLabel.Text + adItem.ToString() + "";
}
// Get the Discount
// Create a targeting profile
// ctx is still active
// Get a ContentSelector and set its properties
ContentSelector csoDiscount =
ctx.TargetingSystem.SelectionContexts["discounts"].GetSelector();
csoDiscount.TraceMode = true;
csoDiscount.ItemsRequested = 1;
if(null != userProfile)
{
csoDiscount.Profiles.Add("User", userProfile);
}
// Get the content using CS2002 Content Selection Framework
StringCollection discountPayload = csoDiscount.GetContent();
foreach (string discountItem in discountPayload)
{
discountLabel.Text = discountLabel.Text + discountItem.ToString() + "";
}
I registered a user of type female contractor and logged in.But still
discount image does not show.
But though the ad. image is showing but discount image is not showing.
In the debug mode I saw that the variable 'adpayload' has count of 1 so
the
corresponding for loop is running once and showing the ad. image.
But the variable 'discountPayload' is showing count 0 ,so the following
for
loop is not running and no image for discount is showing.
I am using commerce server 2002 with SP#3 feature pack 1 default
recomendation.
Please suggest if the code is correct??If not give some sample code...
How does the discount show on the website???
Please give the details step by step procedure.