Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > basket guest
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 13th July 15:19
fran
External User
 
Posts: 1
Default basket guest



Somebody can give me some source code (or help) to store
the basket of a guest and after to force to him to do
login without losing its basket.
Thanks.
  Reply With Quote


  sponsored links


2 21st July 11:24
max akbar
External User
 
Posts: 1
Default basket guest



Code from retail2002.

Good luck,
-Max

//================================================== ========================
===
// FileName : BasketMerger.cs
// Description : Component level helper Class to implement basket
merging when anonymous user signs
// on to different identity (userid has changed) and hence needs to
merge his old basket with the new basket.
//
// This file is part of the Microsoft Commerce Server 2002 SDK
//
// Copyright (c) Microsoft Corporation. All Rights Reserved.
//
// This source code is intended only as a supplement to Microsoft
// Commerce Server 2002 and/or on-line do***entation. See these other
// materials for detailed information regarding Microsoft code samples.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
//================================================== ========================
===

#region Namespaces
using System;
using System.Web;
using Microsoft.CommerceServer.Runtime;
using Microsoft.CommerceServer.Runtime.Orders;
#endregion


namespace Microsoft.CommerceServer.Site.Components
{
/// <summary>
/// Summary description for BasketMerger.
/// </summary>
public class BasketMerger
{
#region Methods


//================================================== ========================
===
// METHOD: MoveItemsFromAnonymousToAuthenticatedBasket
//
// <doc>
// <desc>Public Method</desc>
// <remarks>
// This method is used to merge basket contents
// when a transition from Anonymous to Authenticated user's
state takes place
// (through a previous delete cookies operation).
// </remarks>
// </doc>
//

//================================================== ========================
===

static public void
MoveItemsFromAnonymousToAuthenticatedBasket(System .Guid anonymousGuid,
System.Guid authenticatedGuid)
{
OrderTemplate anonymousOrderTemplate;
Basket authenticatedBasket;

try
{
//
// Proceed only if the userIDs are different...
//

if (!anonymousGuid.Equals(authenticatedGuid))
{
// Retrieve the respective anon and auth baskets now..

anonymousOrderTemplate =
CommerceContext.Current.OrderSystem.GetOrderTempla te(anonymousGuid,
anonymousGuid);

//
// Proceed only if there existed a basket with the
anonymous user..
//
if (anonymousOrderTemplate != null)
{
authenticatedBasket =
CommerceContext.Current.OrderSystem.GetBasket(auth enticatedGuid);

// Merge them now..

authenticatedBasket.Add(anonymousOrderTemplate);
authenticatedBasket.Save();

// delete the anon basket as this user doesnt need
it anymore..

anonymousOrderTemplate.Delete();
}
}
}
catch (Exception)
{
//
// Exception handling yet to be done..
//
}
}

#endregion
}
}
  Reply With Quote
3 21st July 11:24
michael odonovan [msft]
External User
 
Posts: 1
Default basket guest


Hi,

There is good sample code in the MSIB 2.1 AdventureWorks site. Look at the
MoveAnonymousInfoToAuthenticatedUser method in the SiteAuthPolicyValidator
class. This does exactly what you are looking for.

In the AdventureWorks site MoveAnonymousInfoToAuthenticatedUser is called
from login.aspx.

Hope this helps,
Michael

--
This posting is provided "AS IS" with no warranties, and confers no rights.
  Reply With Quote
4 21st July 11:24
michael odonovan [msft]
External User
 
Posts: 1
Default basket guest


Just to add, you can get MSIB 2.1 from

http://www.microsoft.com/downloads/details.aspx?FamilyID=3347ea8e-ed23-41e5-b77b-5ffb542106e9&DisplayLang=en

Hope this helps

--
This posting is provided "AS IS" with no warranties, and confers no rights.
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666