public async Task AddItemToCart(AddCartItemInput input) { var userId = GetUserId(); //here we have some global settings var tenant = await GetCurrentTenantAsync(); // create the cart if not exits otherwise get the current cart var cart = await _cartManager.CreateCart(new Cart(input.TenantId, tenant.Currency, userId)); // get the product that we'll add to the cart var productVariant = await _productManager.GetProductVariantAsync(input.ProductVariantId); var discount = _clientManager.GetClientDiscountByItemGroupCode(input.CardCode, productVariant.ItemGroup); var cartItem = new CartProductItem(input.TenantId, cart.Id, productVariant.Id, input.Quantity, productVariant.Price, tenant.ISV, discount); //finally add the item to the cart await _cartManager.CreateCartProductItem(cartItem); }