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
cartOrderpostfixstringorderLineTypestringquantityCheckbooladdToCartboolproductUrlstringpageIdintnewOrderLinesOrderLineCollection
Returns
AddProducts(IEnumerable<CartProductInfo>, int?)
public void AddProducts(IEnumerable<CartProductInfo> products, int? favoriteListId = 0)
Parameters
productsIEnumerable<CartProductInfo>favoriteListIdint?
CartIsPresent()
Checks whether the cart exists or not. In session or in cookie.
public bool CartIsPresent()
Returns
- bool
trueif XXXX,falseotherwise.
CheckoutStart(Order)
public void CheckoutStart(Order order)
Parameters
orderOrder
ClearCart()
public void ClearCart()
CopyCustomerFieldsToDelivery(Order)
public void CopyCustomerFieldsToDelivery(Order order)
Parameters
orderOrder
CreateCartLineFromModel(Order, OrderLineViewModel)
public OrderLine? CreateCartLineFromModel(Order cart, OrderLineViewModel cartItem)
Parameters
cartOrdercartItemOrderLineViewModel
Returns
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
orderOrderThe Order.
Empty()
public void Empty()
GetActiveCartId(int)
Gets the latest active cart id by user id.
public string? GetActiveCartId(int userId)
Parameters
userIdintUser id.
Returns
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
userIdint
OrderLineBuilder(Order, OrderLineBuilderConfig)
Builds an OrderLine based on the given OrderLineBuilderConfig.
public OrderLine? OrderLineBuilder(Order order, OrderLineBuilderConfig builderConfiguration)
Parameters
orderOrderbuilderConfigurationOrderLineBuilderConfigThe builder configuration.
Returns
RemoveOrderLine(Order, string)
public void RemoveOrderLine(Order cart, string orderlineId)
Parameters
SaveCart()
public void SaveCart()
SetActiveCartOnUser(Order)
public void SetActiveCartOnUser(Order order)
Parameters
orderOrder
SetActiveCartOnuser(Order, User)
public void SetActiveCartOnuser(Order order, User user)
Parameters
SetUserCart(Order, User, bool)
public void SetUserCart(Order order, User user, bool isNew)
Parameters
SetUserCart(Order, bool)
public void SetUserCart(Order order, bool isNew)
Parameters
UpdateCartFromModel(Order, OrderViewModel)
public void UpdateCartFromModel(Order cart, OrderViewModel cartModel)
Parameters
cartOrdercartModelOrderViewModel
UpdateCartLineFromModel(OrderLine, OrderLineViewModel)
public void UpdateCartLineFromModel(OrderLine orderLine, OrderLineViewModel cartItem)
Parameters
orderLineOrderLinecartItemOrderLineViewModel
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
cartOrderThe cart the model will be applied to.
cartModelOrderViewModelThe model carrying CustomerAddressId and DeliveryAddressId.
Returns
- string
A message describing the first invalid address id, or
nullwhen 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
cartOrderThe cart the model will be applied to.
cartModelOrderViewModelThe model carrying CustomerAddressId and DeliveryAddressId.
adoptingUserIdintThe 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
nullwhen 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.