public virtual MiniCartViewModel CreateMiniCartViewModel(ICart cart)
 {
     if (cart == null)
     {
         return(new MiniCartViewModel
         {
             ItemCount = 0,
             CheckoutPage = _contentLoader.Get <StartPage>(ContentReference.StartPage).CheckoutPage,
             Shipments = Enumerable.Empty <ShipmentViewModel>(),
             Total = new Money(0, _currencyService.GetCurrentCurrency())
         });
     }
     return(new MiniCartViewModel
     {
         ItemCount = GetLineItemsTotalQuantity(cart),
         CheckoutPage = _contentLoader.Get <StartPage>(ContentReference.StartPage).CheckoutPage,
         Shipments = _shipmentViewModelFactory.CreateShipmentsViewModel(cart),
         Total = _orderGroupCalculator.GetSubTotal(cart) + _orderGroupCalculator.GetOrderDiscountTotal(cart, cart.Currency)
     });
 }
示例#2
0
 public virtual MiniCartViewModel CreateMiniCartViewModel(ICart cart)
 {
     if (cart == null)
     {
         return(new MiniCartViewModel
         {
             ItemCount = 0,
             CheckoutPage = _contentLoader.Get <StartPage>(ContentReference.StartPage).CheckoutPage,
             Shipments = Enumerable.Empty <ShipmentViewModel>(),
             Total = _pricingService.GetMoney(0)
         });
     }
     return(new MiniCartViewModel
     {
         ItemCount = GetCartLineItems(cart).Sum(x => x.Quantity),
         CheckoutPage = _contentLoader.Get <StartPage>(ContentReference.StartPage).CheckoutPage,
         Shipments = _shipmentViewModelFactory.CreateShipmentsViewModel(cart),
         Total = _orderGroupCalculator.GetSubTotal(cart)
     });
 }
        public virtual MiniCartViewModel CreateMiniCartViewModel(ICart cart)
        {
            if (cart == null)
            {
                return(new MiniCartViewModel
                {
                    ItemCount = 0,
                    CheckoutPage = _contentLoader.Get <StartPage>(ContentReference.StartPage).CheckoutPage,
                    Shipments = Enumerable.Empty <ShipmentViewModel>(),
                    Total = new Money(0, _currencyService.GetCurrentCurrency()),
                    CurrentCustomer = _customerService.GetCurrentContact(),
                    IsQuotedCart = false
                });
            }

            // If order comes from a quoted order.
            var quotedCart = false;

            if (cart.Properties[Constants.Quote.ParentOrderGroupId] != null)
            {
                int orderLink = int.Parse(cart.Properties[Constants.Quote.ParentOrderGroupId].ToString());
                if (orderLink != 0)
                {
                    quotedCart = true;
                }
            }
            return(new MiniCartViewModel
            {
                ItemCount = GetLineItemsTotalQuantity(cart),
                CheckoutPage = _contentLoader.Get <StartPage>(ContentReference.StartPage).CheckoutPage,
                Shipments = _shipmentViewModelFactory.CreateShipmentsViewModel(cart),
                Total = _orderGroupCalculator.GetSubTotal(cart),
                IsQuotedCart = quotedCart,
                CurrentCustomer = _customerService.GetCurrentContact()
            });
        }