Class Cart
Represents the Shopping Cart in the system. User can have unlimited number of carts which can be used for such features as Wish List, Wedding Registry and so on. Each of them will need to have a unique card name. The Cart with a DefaultName specified by the DefaultName property will be considered primary cart.
Implements
Inherited Members
Namespace: Mediachase.Commerce.Orders
Assembly: Mediachase.Commerce.dll
Version: 10.8.0Syntax
public class Cart : OrderGroup, IXmlSerializable, IStorageObject, ICloneable, ISerializable, ICart, IOrderGroup, IExtendedProperties, IDeepCloneable
Constructors
Cart()
Initializes a new instance of the Cart class.
Declaration
protected Cart()
Cart(IDataReader)
Internal constructor required by collection implementation.
Declaration
public Cart(IDataReader reader)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Data.IDataReader | reader | The reader. |
Cart(SerializationInfo, StreamingContext)
Initializes a new instance of the Cart class.
Declaration
protected Cart(SerializationInfo info, StreamingContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Runtime.Serialization.SerializationInfo | info | The info. |
| System.Runtime.Serialization.StreamingContext | context | The context. |
Cart(String, Guid)
Initializes a new instance of the Cart class.
Declaration
public Cart(string Name, Guid CustomerId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Name | The name. |
| System.Guid | CustomerId | The customer id. |
Properties
DefaultName
Gets the default name for the cart.
Declaration
public static string DefaultName { get; }
Property Value
| Type | Description |
|---|---|
| System.String | default name for the cart. |
ExchangeName
Gets the exchange name for the cart.
Declaration
public static string ExchangeName { get; }
Property Value
| Type | Description |
|---|---|
| System.String | exchange name for the cart. |
OrderNumberMethod
Gets or sets the order number method that is used to generate the tracking PO sequence. If none set, the framework will use built in function GenerateOrderNumber:
this.OrderNumberMethod = new CreateOrderNumber(GenerateOrderNumber);
private string GenerateOrderNumber(Cart cart) { string num = new Random().Next(100, 999).ToString(); return String.Format("PO{0}{1}", cart.OrderGroupId, num); }
Declaration
public Cart.CreateOrderNumber OrderNumberMethod { get; set; }
Property Value
| Type | Description |
|---|---|
| Cart.CreateOrderNumber | The order number method. |
WishListName
Gets the name for the Wishlist.
Declaration
public static string WishListName { get; }
Property Value
| Type | Description |
|---|---|
| System.String | name for the Wishlist. |
Methods
AcceptChanges()
Accepts the changes.
Declaration
public override void AcceptChanges()
Overrides
Exceptions
| Type | Condition |
|---|---|
| OrderException | If a cart with same CustomerId, Name, and MarketId already exist. |
Add(OrderGroup)
Adds the specified order group to the existing cart.
Declaration
public void Add(OrderGroup orderGroup)
Parameters
| Type | Name | Description |
|---|---|---|
| OrderGroup | orderGroup | The order group. |
Add(OrderGroup, Boolean)
Adds the specified order group to the existing cart.
Declaration
public void Add(OrderGroup orderGroup, bool lineItemRollup)
Parameters
| Type | Name | Description |
|---|---|---|
| OrderGroup | orderGroup | The order group. |
| System.Boolean | lineItemRollup | if set to |
GenerateOrderNumber(Cart)
Generates the order number.
Declaration
public string GenerateOrderNumber(Cart cart)
Parameters
| Type | Name | Description |
|---|---|---|
| Cart | cart | The cart. |
Returns
| Type | Description |
|---|---|
| System.String |
GetObjectData(SerializationInfo, StreamingContext)
Gets the object data.
Declaration
public override void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Runtime.Serialization.SerializationInfo | info | The info. |
| System.Runtime.Serialization.StreamingContext | context | The context. |
Overrides
LoadByCustomer(Guid)
Loads cart by customer.
Declaration
public static MetaStorageCollectionBase<Cart> LoadByCustomer(Guid CustomerId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Guid | CustomerId | The customer id. |
Returns
| Type | Description |
|---|---|
| MetaStorageCollectionBase<Cart> |
LoadByCustomerAndOrderGroupId(Guid, Int32)
Loads cart by customer and order group id.
Declaration
[Obsolete("This method is no longer used, use LoadByOrderGroupId instead. Will remain at least until April 2016.")]
public static Cart LoadByCustomerAndOrderGroupId(Guid customerId, int orderGroupId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Guid | customerId | The customer id. |
| System.Int32 | orderGroupId | The order group id. |
Returns
| Type | Description |
|---|---|
| Cart |
LoadByOrderGroupId(Int32)
Loads the by order group id.
Declaration
public static Cart LoadByOrderGroupId(int orderGroupId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | orderGroupId | The order group identifier. |
Returns
| Type | Description |
|---|---|
| Cart |
LoadCartsByCustomerAndName(Guid, String)
Declaration
public static IEnumerable<Cart> LoadCartsByCustomerAndName(Guid customerId, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Guid | customerId | |
| System.String | name |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<Cart> |
LoadSingleCartByCustomerAndName(Guid, String)
Loads a single cart by customer and cart name.
Declaration
public static Cart LoadSingleCartByCustomerAndName(Guid customerId, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Guid | customerId | The customer id. |
| System.String | name | The cart name. |
Returns
| Type | Description |
|---|---|
| Cart | The matching cart, or null if no matching cart was found. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown if multiple matching carts are found. |
SaveAsPaymentPlan()
Saves the cart as payment plan, typically the last step in the checkout.
Declaration
public virtual PaymentPlan SaveAsPaymentPlan()
Returns
| Type | Description |
|---|---|
| PaymentPlan | The payment plan |
SaveAsPurchaseOrder()
Saves the cart as purchase order, typically the last step in the checkout. The original cart will need to be deleted and is not handled by this script.
Declaration
public virtual PurchaseOrder SaveAsPurchaseOrder()
Returns
| Type | Description |
|---|---|
| PurchaseOrder | The purchase order |
Search(OrderSearch, out Int32)
Searches for the cart.
Declaration
public static MetaStorageCollectionBase<Cart> Search(OrderSearch search, out int totalRecords)
Parameters
| Type | Name | Description |
|---|---|---|
| OrderSearch | search | The search. |
| System.Int32 | totalRecords | The total records. |
Returns
| Type | Description |
|---|---|
| MetaStorageCollectionBase<Cart> |
WriteXml(XmlWriter)
Converts an object into its XML representation.
Declaration
public override void WriteXml(XmlWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlWriter | writer | The System.Xml.XmlWriter stream to which the object is serialized |
Overrides
Explicit Interface Implementations
IDeepCloneable.DeepClone()
Creates a limited deep clone of this object.
Declaration
object IDeepCloneable.DeepClone()
Returns
| Type | Description |
|---|---|
| System.Object | A deep clone of this object. |
Remarks
Some reference type properties will NOT be cloned by this method - the original and the clone will share the same instance of: