Class CartHelper
Cart helper class used to simplify cart operations. The cart is automatically cached in the current Http Context.
Inheritance
Inherited Members
Namespace: Mediachase.Commerce.Website.Helpers
Assembly: Mediachase.Commerce.Website.dll
Version: 10.8.0Syntax
public class CartHelper
Constructors
CartHelper(Cart)
Initializes a new instance of the CartHelper class.
Declaration
public CartHelper(Cart cart)
Parameters
| Type | Name | Description |
|---|---|---|
| Cart | cart | The cart. |
CartHelper(String)
Initializes a new instance of the CartHelper class.
Declaration
public CartHelper(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
CartHelper(String, Guid)
Initializes a new instance of the CartHelper class.
Declaration
public CartHelper(string name, Guid userId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
| System.Guid | userId | The user id. |
CartHelper(String, Guid, IMarket)
Initializes a new instance of the CartHelper class.
Declaration
public CartHelper(string name, Guid userId, IMarket market)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of cart |
| System.Guid | userId | The User Id. |
| IMarket | market | The market. |
Fields
WishListName
Default name for the cart.
Declaration
public static string WishListName
Field Value
| Type | Description |
|---|---|
| System.String |
Properties
Cart
Gets the cart.
Declaration
public virtual Cart Cart { get; }
Property Value
| Type | Description |
|---|---|
| Cart | The cart. |
EntryDescriptionMetaFieldName
Declaration
public string EntryDescriptionMetaFieldName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
IsAddressRequired
Gets a value indicating whether this instance is address required.
Declaration
public virtual bool IsAddressRequired { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
IsEmpty
Gets a value indicating whether this instance is empty.
Declaration
public virtual bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
LineItems
Gets the line items.
Declaration
public virtual IEnumerable<LineItem> LineItems { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<LineItem> | The line items. |
OrderForm
Gets the order form.
Declaration
public virtual OrderForm OrderForm { get; }
Property Value
| Type | Description |
|---|---|
| OrderForm | The order form. |
PrimaryAddress
Gets the primary address.
Declaration
public virtual OrderAddress PrimaryAddress { get; }
Property Value
| Type | Description |
|---|---|
| OrderAddress | The primary address. |
Methods
AddEntry(Entry)
Adds the entry. Line item's qty will be increased by 1.
Declaration
public virtual LineItem AddEntry(Entry entry)
Parameters
| Type | Name | Description |
|---|---|---|
| Entry | entry | The entry. |
Returns
| Type | Description |
|---|---|
| LineItem | The line item. |
AddEntry(Entry, CartHelper[])
Adds the entry. Line item's qty will be increased by 1.
Declaration
public virtual LineItem AddEntry(Entry entry, params CartHelper[] helpersToRemove)
Parameters
| Type | Name | Description |
|---|---|---|
| Entry | entry | The entry. |
| CartHelper[] | helpersToRemove |
Returns
| Type | Description |
|---|---|
| LineItem | The line item. |
AddEntry(Entry, Boolean)
Adds the entry.
Declaration
public virtual LineItem AddEntry(Entry entry, bool fixedQuantity)
Parameters
| Type | Name | Description |
|---|---|---|
| Entry | entry | The entry. |
| System.Boolean | fixedQuantity | If true, lineitem's qty will be set to |
Returns
| Type | Description |
|---|---|
| LineItem | The line item. |
AddEntry(Entry, Boolean, CartHelper[])
Adds the entry.
Declaration
public virtual LineItem AddEntry(Entry entry, bool fixedQuantity, params CartHelper[] helpersToRemove)
Parameters
| Type | Name | Description |
|---|---|---|
| Entry | entry | The entry. |
| System.Boolean | fixedQuantity | If true, lineitem's qty will be set to |
| CartHelper[] | helpersToRemove |
Returns
| Type | Description |
|---|---|
| LineItem | The line item. |
AddEntry(Entry, Decimal, Boolean, CartHelper[])
Adds the entry with default warehouse code
Declaration
public virtual LineItem AddEntry(Entry entry, decimal quantity, bool fixedQuantity, params CartHelper[] helpersToRemove)
Parameters
| Type | Name | Description |
|---|---|---|
| Entry | entry | The entry. |
| System.Decimal | quantity | The quantity. |
| System.Boolean | fixedQuantity | If true, lineitem's qty will be set to |
| CartHelper[] | helpersToRemove | CartHelper(s) from which the item needs to be removed simultaneously with adding it to the current CartHelper. |
Returns
| Type | Description |
|---|---|
| LineItem | The line item. |
AddEntry(Entry, Decimal, Boolean, String, CartHelper[])
Adds the entry.
Declaration
public virtual LineItem AddEntry(Entry entry, decimal quantity, bool fixedQuantity, string warehouseCode, params CartHelper[] helpersToRemove)
Parameters
| Type | Name | Description |
|---|---|---|
| Entry | entry | The entry. |
| System.Decimal | quantity | The quantity. |
| System.Boolean | fixedQuantity | If true, lineitem's qty will be set to |
| System.String | warehouseCode | The warehouse code |
| CartHelper[] | helpersToRemove | CartHelper(s) from which the item needs to be removed simultaneously with adding it to the current CartHelper. |
Returns
| Type | Description |
|---|---|
| LineItem | The line item. |
AddItemToFirstShipment(Int32, Decimal)
Declaration
[Obsolete("This method is no longer called from any EPiServer API. Use 'AddItemToShipment' with warehouseCode parameter instead. Will remain at least until October 2017.")]
protected void AddItemToFirstShipment(int lineItemIndex, decimal quantity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | lineItemIndex | |
| System.Decimal | quantity |
AddItemToShipment(Int32, Decimal, String)
Declaration
protected void AddItemToShipment(int lineItemIndex, decimal quantity, string warehouseCode)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | lineItemIndex | |
| System.Decimal | quantity | |
| System.String | warehouseCode |
AddLastItemToFirstShipment()
Declaration
[Obsolete("This method is no longer called from any EPiServer API. Use 'AddItemToFirstShipment' instead. Will remain at least until July 2016.")]
protected void AddLastItemToFirstShipment()
ClearShippingInfo(OrderForm)
Clears the shipping information.
Declaration
public virtual void ClearShippingInfo(OrderForm orderForm)
Parameters
| Type | Name | Description |
|---|---|---|
| OrderForm | orderForm | The order form. |
Delete()
Deletes the current basket instance from the database.
Declaration
public virtual void Delete()
FindAddressById(String)
Finds the address by id.
Declaration
public virtual OrderAddress FindAddressById(string addressId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | addressId | The address id. |
Returns
| Type | Description |
|---|---|
| OrderAddress |
FindAddressByName(String)
Finds the name of the address by.
Declaration
public virtual OrderAddress FindAddressByName(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
Returns
| Type | Description |
|---|---|
| OrderAddress |
GetCacheKey(String, Guid, MarketId)
Gets the cache key which is used to store current cart in the http context, by a specific market.
Declaration
protected virtual string GetCacheKey(string name, Guid userId, MarketId marketId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
| System.Guid | userId | The user id. |
| MarketId | marketId | The market id. |
Returns
| Type | Description |
|---|---|
| System.String |
GetCartPromotions()
Gets all of the cart promotions regardless of promotion type.
Declaration
public IEnumerable<string> GetCartPromotions()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.String> |
GetCartPromotions(Nullable<PromotionGroup.PromotionGroupKey>)
Gets the cart promotions based on promotion type or All.
Declaration
public IEnumerable<string> GetCartPromotions(PromotionGroup.PromotionGroupKey? promoKey)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Nullable<PromotionGroup.PromotionGroupKey> | promoKey | The promotion group key. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.String> |
GetOrderForm()
Gets the default OrderForm.
Declaration
public virtual OrderForm GetOrderForm()
Returns
| Type | Description |
|---|---|
| OrderForm | the default OrderForm |
GetOrderForm(String)
Gets the named OrderForm.
Declaration
public virtual OrderForm GetOrderForm(string orderFormName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | orderFormName | The name of the OrderForm object to retrieve. |
Returns
| Type | Description |
|---|---|
| OrderForm | The named OrderForm. |
GetTotalItemCount()
Gets the total number of items in the basket.
Declaration
public virtual decimal GetTotalItemCount()
Returns
| Type | Description |
|---|---|
| System.Decimal | the total number of items in the basket. |
LoadCart(String, Guid)
Loads the cart. The cart is loaded from current http context if one is present.
Declaration
protected virtual void LoadCart(string name, Guid userId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
| System.Guid | userId | The user id. |
Remarks
Uses the market returned from ICurrentMarket for a market id.
LoadCart(String, Guid, MarketId)
Loads the cart. The cart is loaded from current http context if one is present.
Declaration
protected virtual void LoadCart(string name, Guid userId, MarketId marketId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
| System.Guid | userId | The user id. |
| MarketId | marketId | The market id. |
MergeShipments()
Merge all shipments of order forms into one for each form.
Declaration
public void MergeShipments()
MergeShipments(OrderForm)
Merge all shipments of an order form.
Declaration
public void MergeShipments(OrderForm form)
Parameters
| Type | Name | Description |
|---|---|---|
| OrderForm | form | The order form |
Reset()
Resets this instance. Will clean up line items, remove payments and delete addresses. The cart needs to be saved in order for changes to be persisted.
Declaration
public virtual void Reset()
RunWorkflow(String)
Runs the workflow and generates the error message for all the warnings.
Declaration
public virtual void RunWorkflow(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name. |
RunWorkflow(String, Dictionary<String, Object>)
Runs the workflow and generates the error message for all the warnings.
Declaration
public virtual void RunWorkflow(string name, Dictionary<string, object> param)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The workflow name. |
| System.Collections.Generic.Dictionary<System.String, System.Object> | param | The workflow parameters. |