← API documentation Services

ICartService

Get or reset the current visitor's cart.

Last updated

Usage

The cart service is scoped. ICartActionService handles mutations of individual order lines.

Member Purpose
GetCart(bool includeFinalizedOrder = false) Gets the cart for the current context.
FlushCart(bool deleteLines = false) Resets the cart and can delete its order lines.
CreateCartOrderAndUpdateSessionAndCookie() Creates an order for the cart and updates the session and cookie.
ApplyOrderNumber(Order) Assigns an order number.
csharp
var cart = cartService.GetCart();
var lines = cart.Order.OrderLines;

Source: OptimusCommercev2.Core/Interfaces/ICartService.cs · OptimusCommerce.Extension 17.94.0