public virtual OrderSummaryViewModel CreateOrderSummaryViewModel(ICart cart) { if (cart == null) { return(CreateEmptyOrderSummaryViewModel()); } var totals = _orderGroupCalculator.GetOrderGroupTotals(cart); return(new OrderSummaryViewModel { SubTotal = totals.SubTotal, CartTotal = totals.Total, ShippingTotal = totals.ShippingTotal, ShippingSubtotal = _orderGroupCalculator.GetShippingSubTotal(cart), OrderDiscountTotal = _orderGroupCalculator.GetOrderDiscountTotal(cart), ShippingDiscountTotal = cart.GetShippingDiscountTotal(), ShippingTaxTotal = totals.ShippingTotal + totals.TaxTotal, TaxTotal = totals.TaxTotal, PaymentTotal = cart.Currency.Round(totals.Total.Amount - (cart.GetFirstForm().Payments?.Sum(x => x.Amount) ?? 0)), OrderDiscounts = cart.GetFirstForm().Promotions.Where(x => x.DiscountType == DiscountType.Order).Select(x => new OrderDiscountViewModel { Discount = new Money(x.SavedAmount, new Currency(cart.Currency)), DisplayName = x.Description }) }); }