Table of Contents

Class CartService

Namespace
Dynamicweb.Ecommerce.Frontend.Cart
Assembly
Dynamicweb.Ecommerce.dll
public class CartService
Inheritance
CartService
Inherited Members

Methods

AddOrderLine(Order, string?, string?, bool, bool, string?, int, ref OrderLineCollection)

public OrderLine? AddOrderLine(Order cart, string? postfix, string? orderLineType, bool quantityCheck, bool addToCart, string? productUrl, int pageId, ref OrderLineCollection newOrderLines)

Parameters

cart Order
postfix string
orderLineType string
quantityCheck bool
addToCart bool
productUrl string
pageId int
newOrderLines OrderLineCollection

Returns

OrderLine

AddProducts(IEnumerable<CartProductInfo>, int?)

public void AddProducts(IEnumerable<CartProductInfo> products, int? favoriteListId = 0)

Parameters

products IEnumerable<CartProductInfo>
favoriteListId int?

CartIsPresent()

Checks whether the cart exists or not. In session or in cookie.

public bool CartIsPresent()

Returns

bool

true if XXXX, false otherwise.

CheckoutStart(Order)

public void CheckoutStart(Order order)

Parameters

order Order

ClearCart()

public void ClearCart()

CopyCustomerFieldsToDelivery(Order)

public void CopyCustomerFieldsToDelivery(Order order)

Parameters

order Order

CreateCartLineFromModel(Order, OrderLineViewModel)

public OrderLine? CreateCartLineFromModel(Order cart, OrderLineViewModel cartItem)

Parameters

cart Order
cartItem OrderLineViewModel

Returns

OrderLine

CreateOrder(Order)

Convert a cart into an order and finish it up.

  • Upgrade cart to order
  • Set order complete and handle stock
  • Set checkout done and removes stock reserve, handles taxes, handles gift card (use and buy), handle loyalty points (use and earn)
public void CreateOrder(Order order)

Parameters

order Order

The Order.

Empty()

public void Empty()

GetActiveCartId(int)

Gets the latest active cart id by user id.

public string? GetActiveCartId(int userId)

Parameters

userId int

User id.

Returns

string

LoadCart()

Loads the cart into session. Checks for cart on AccessUser and cookie.

public void LoadCart()

LoadCart(int)

Loads the cart into session. Checks for cart on AccessUser and cookie.

public void LoadCart(int userId)

Parameters

userId int

OrderLineBuilder(Order, OrderLineBuilderConfig)

Builds an OrderLine based on the given OrderLineBuilderConfig.

public OrderLine? OrderLineBuilder(Order order, OrderLineBuilderConfig builderConfiguration)

Parameters

order Order
builderConfiguration OrderLineBuilderConfig

The builder configuration.

Returns

OrderLine

The OrderLine.

RemoveOrderLine(Order, string)

public void RemoveOrderLine(Order cart, string orderlineId)

Parameters

cart Order
orderlineId string

SaveCart()

public void SaveCart()

SetActiveCartOnUser(Order)

public void SetActiveCartOnUser(Order order)

Parameters

order Order

SetActiveCartOnuser(Order, User)

public void SetActiveCartOnuser(Order order, User user)

Parameters

order Order
user User

SetUserCart(Order, User, bool)

public void SetUserCart(Order order, User user, bool isNew)

Parameters

order Order
user User
isNew bool

SetUserCart(Order, bool)

public void SetUserCart(Order order, bool isNew)

Parameters

order Order
isNew bool

UpdateCartFromModel(Order, OrderViewModel)

public void UpdateCartFromModel(Order cart, OrderViewModel cartModel)

Parameters

cart Order
cartModel OrderViewModel

UpdateCartLineFromModel(OrderLine, OrderLineViewModel)

public void UpdateCartLineFromModel(OrderLine orderLine, OrderLineViewModel cartItem)

Parameters

orderLine OrderLine
cartItem OrderLineViewModel

UpdateOrderLines()

public void UpdateOrderLines()

ValidateCartAddressIds(Order, OrderViewModel)

Validates the saved address ids on cartModel before it is applied to cart with UpdateCartFromModel(Order, OrderViewModel).

public string? ValidateCartAddressIds(Order cart, OrderViewModel cartModel)

Parameters

cart Order

The cart the model will be applied to.

cartModel OrderViewModel

The model carrying CustomerAddressId and DeliveryAddressId.

Returns

string

A message describing the first invalid address id, or null when the ids can be used.

Remarks

A customer address id must be an active address of the cart's customer. A delivery address id must be an active address of the cart's customer, or of a user or user group sharing that customer's customer number. An id of 0 is not validated.

ValidateCartAddressIds(Order, OrderViewModel, int)

Validates the saved address ids on cartModel before it is applied to cart with UpdateCartFromModel(Order, OrderViewModel), for a request that assigns a cart without a customer to adoptingUserId before the model is applied.

[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Instance API next to UpdateCartFromModel, called on the injected CartService.")]
public string? ValidateCartAddressIds(Order cart, OrderViewModel cartModel, int adoptingUserId)

Parameters

cart Order

The cart the model will be applied to.

cartModel OrderViewModel

The model carrying CustomerAddressId and DeliveryAddressId.

adoptingUserId int

The user the cart is assigned to when it has no customer, or 0 when it is not taken over.

Returns

string

A message describing the first invalid address id, or null when the ids can be used.

Remarks

The ids are validated against the customer the cart has once the request is applied: CustomerUserId when it is set, otherwise the cart's current customer, otherwise adoptingUserId.

To top