Share via


OrderContext.GetBasket (Guid) Method (BCL)

Use this method to retrieve an existing basket instance, or create a new one if it does not exist.

Definition

[Visual Basic .NET]

Public Function GetBasket( _ByValbasketID As System.Guid _
) As Basket

[C#]

public Basket GetBasket(System.GuidbasketID);

Parameters

[Visual Basic .NET]

  • basketID
    The OrderGroupID property for baskets is set equal to the basketID. The user ID for the current user is most commonly used as the basketID.

[C#]

  • basketID
    The OrderGroupID property of a basket is set to the basket ID. The userID for the current user is most commonly used as the basketID.

Return Value

The existing populated basket instance, or a new empty basket instance, if one is not found.

Example

using Microsoft.CommerceServer.Runtime;
using Microsoft.CommerceServer.Runtime.Orders;

private OrderGroup CreateBasket()
{
   CommerceContext csContext = CommerceContext.Current;
   
   // Get the user's user Id
   //Guid userID = new Guid(csContext.UserID);         
   // For this sample, we'll generate a new Unique UserID:
   Guid userID = Guid.NewGuid();
   
   // GetBasket() will load a user's existing basket, if it exists,
   // otherwise it will create a new, empty basket
   Basket basket = csContext.OrderSystem.GetBasket(userID);
   
   // If this is a new basket, then create a default OrderForm
   if (basket.OrderForms.Count < 1)
      basket.OrderForms.Add(new OrderForm("default"));

   return basket;
}

Requirements

Namespace: Microsoft.CommerceServer.Runtime.Orders

Platforms: Windows 2000, Windows Server 2003

Assembly: Microsoft.CommerceServer.Runtime.dll

See Also

Example Code for the Microsoft.CommerceServer.Runtime.Orders Namespace

Copyright © 2005 Microsoft Corporation.
All rights reserved.