Example #1
0
        /// <summary>
        /// digging OrderItems details
        /// </summary>
        /// <param name="orderView"></param>
        private void LoadPreOrderDetails(MyHLShoppingCartView orderView)
        {
            if (_orderChinaProviderLoader == null)
                _orderChinaProviderLoader = new OrderChinaProviderLoader();

            var orderDetails = _orderChinaProviderLoader.GetPreOrderDetail(orderView.DistributorID, orderView.OrderHeaderId);
            var shippingInfo = (ShippingInfo_V01)orderDetails.Shipment;
            if (shippingInfo != null && shippingInfo.Address != null)
            {
                orderView.Recipient = shippingInfo.Recipient;
                orderView.Address = shippingInfo.Address.Line1 + shippingInfo.Address.City + shippingInfo.Address.CountyDistrict;
                orderView.AddressValue = ObjectMappingHelper.Instance.GetToShipping(shippingInfo.Address);
            }

            var items = orderDetails.OrderItems;
            if (items != null)
            {
                var cartItems = (from OrderItem_V02 item in items
                                 select
                                     new MyHLProductItemView()
                                     {
                                         Quantity = item.Quantity,
                                         SKU = item.SKU,
                                         Description = item.Description,
                                         RetailPrice = item.RetailPrice
                                     }).ToList();

                orderView.CartItems = cartItems;
            }
        }
Example #2
0
        static bool IsAllVirtualOrder(MyHLShoppingCartView orderView, List<string> virtualProduct)
        {
            bool isAllVirtual = false;

            if (virtualProduct == null || virtualProduct.Count == 0) return false;

            if (orderView.CartItems != null && orderView.CartItems.Count > 0)
            {
                var virtualItems = (from a in orderView.CartItems
                                    where virtualProduct.Any(vp => vp == a.SKU)
                                    select a).ToList();

                if (virtualItems.Count > 0 && (virtualItems.Count == orderView.CartItems.Count))
                {
                    isAllVirtual = true;
                }
            }

            if (isAllVirtual || (orderView.DonationAmount > 0 && (orderView.CartItems == null || orderView.CartItems.Count == 0)))
                return true;
            else
                return false;
        }
Example #3
0
        public List<MyHLShoppingCartView> GetOrdersWithDetail(string distributorId, int customerProfileID, string countryCode, DateTime startOrderDate, DateTime endOrderDate, MyHerbalife3.Ordering.Providers.China.OrderStatusFilterType statusFilter, string filterExpressions, string sortExpressions, bool isNonGDOOrder = false, bool isPreOrdering = false, string orderNumber = null)
        {
            List<MyHLShoppingCartView> result;
            List<OnlineOrder> orderListing = null;
            List<OrderStatusType> ordStsList = new List<OrderStatusType>();
            List<PaymentGatewayRecordStatusType> pgrStsList = new List<PaymentGatewayRecordStatusType>();
            List<PaymentPendingOrderPaymentStatusType> ppoStsList = new List<PaymentPendingOrderPaymentStatusType>();

            if (Settings.GetRequiredAppSetting("GetOrderinfoCache", "true") == "true")
            {
                result = SearchFromCachedList(distributorId, statusFilter, filterExpressions, sortExpressions, startOrderDate, endOrderDate, orderNumber);

                if (result != null)
                {
                    return result;
                }
            }

            result = new List<MyHLShoppingCartView>();

            switch (statusFilter)
            {
                case OrderStatusFilterType.Cancel_Order:
                    ordStsList.Add(OrderStatusType.Cancel_Order);
                    break;

                case OrderStatusFilterType.Complete:
                    ordStsList.Add(OrderStatusType.Complete);
                    break;

                case OrderStatusFilterType.In_Progress:
                    ordStsList.Add(OrderStatusType.In_Progress);
                    break;

                case OrderStatusFilterType.NTS_Printed:
                    ordStsList.Add(OrderStatusType.NTS_Printed);
                    break;

                case OrderStatusFilterType.To_Be_Assign:
                    ordStsList.Add(OrderStatusType.To_Be_Assign);
                    break;

                case OrderStatusFilterType.Payment_Failed:
                case OrderStatusFilterType.Payment_Pending:
                    ordStsList = null;
                    break;
            }

            switch (statusFilter)
            {
                case OrderStatusFilterType.Payment_Pending:
                    pgrStsList.Add(PaymentGatewayRecordStatusType.Unknown);
                    break;

                case OrderStatusFilterType.Cancel_Order:
                    pgrStsList.Add(PaymentGatewayRecordStatusType.CancelledByUser);
                    break;

                case OrderStatusFilterType.Payment_Failed:
                    pgrStsList.Add(PaymentGatewayRecordStatusType.Declined);
                    break;

                case OrderStatusFilterType.All:
                    pgrStsList.Add(PaymentGatewayRecordStatusType.Unknown);
                    pgrStsList.Add(PaymentGatewayRecordStatusType.CancelledByUser);
                    pgrStsList.Add(PaymentGatewayRecordStatusType.Declined);
                    break;
            }

            switch (statusFilter)
            {
                case OrderStatusFilterType.Cancel_Order:
                    ppoStsList.Add(PaymentPendingOrderPaymentStatusType.CNCancelled);
                    break;

                case OrderStatusFilterType.Payment_Pending:
                    ppoStsList.Add(PaymentPendingOrderPaymentStatusType.CNPending);
                    break;

                case OrderStatusFilterType.All:
                    ppoStsList.Add(PaymentPendingOrderPaymentStatusType.CNCancelled);
                    ppoStsList.Add(PaymentPendingOrderPaymentStatusType.CNPending);
                    break;
            }

            var req = new GetOrdersRequest_V02
            {
                CountryCode = countryCode,
                CustomerProfileID = customerProfileID,
                OrderFilter = new OrdersFilter
                {
                    DistributorId = distributorId,
                    StartDate = startOrderDate,
                    EndDate = endOrderDate,
                    OrderStatusList = ordStsList,
                    IsNonGDOOrders = isNonGDOOrder,
                    OrderNumber = orderNumber,
                },
                OrderingType = isPreOrdering ? OrderingType.PreOrder : OrderingType.RSO,
                PaymentGatewayRecordStatusList = pgrStsList,
                PaymentPendingOrderPaymentStatusList = ppoStsList,
            };

            if (_chinaOrderProxy == null)
                _chinaOrderProxy = ServiceClientProvider.GetChinaOrderServiceProxy();

            var rsp = _chinaOrderProxy.GetOrdersWithDetail(new GetOrdersWithDetailRequest(req)).GetOrdersWithDetailResult as GetOrdersResponse_V01;
            if (Helper.Instance.ValidateResponse(rsp))
            {
                orderListing = rsp.Orders;
            }
            else
                LoggerHelper.Error(string.Format("MyHLShoppingCartView.GetOrdersWithDetail() Error. Unsuccessful result from web service ChinaOrderSVC.GetOrdersWithDetail. Data: DistributorId={0}", distributorId));

            bool copyEnabled = true;
            bool hasUnknownOrder = false;
            bool pendingPayment = false;
            List<MyHLProductItemView> cartItems;

            if (Helper.Instance.HasData(orderListing))
            {
                var unknownOrder = (from a in orderListing where a.Status == "未知" select a).FirstOrDefault();

                //dont display feedback, if any order is pending
                if (unknownOrder != null)
                {
                    hasUnknownOrder = true;
                }

                var virtualProduct = GetVirtualProduct();

                foreach (var order in orderListing)
                {
                    var priceInfo = order.Pricing as OrderTotals_V01;
                    var priceInfo_V02 = order.Pricing as OrderTotals_V02;
                    if (priceInfo == null) continue;

                    switch (order.Status)
                    {
                        case "未知": //unknown order
                            copyEnabled = false;
                            pendingPayment = true;
                            break;
                        default:
                            pendingPayment = false;
                            copyEnabled = !hasUnknownOrder;
                            break;
                    }

                    var orderView = new MyHLShoppingCartView
                    {
                        ID = order.ShoppingCartID.ToString(),
                        OrderNumber = order.OrderID ?? string.Empty,
                        Date = order.ReceivedDate.ToString("d", CultureInfo.CurrentCulture),
                        DateTimeForOrder = order.ReceivedDate,
                        VolumePoints = priceInfo.VolumePoints.ToString("00.00"),

                        TotalAmountValue = priceInfo.AmountDue,
                        VolumePointsValue = priceInfo.VolumePoints,

                        ProductTaxTotal = priceInfo_V02 != null ? priceInfo_V02.ProductTaxTotal : decimal.Zero,
                        DonationAmount = priceInfo_V02 != null ? priceInfo_V02.Donation : decimal.Zero,
                        SelfDonationAmount = priceInfo_V02 != null ? priceInfo_V02.SelfDonationAmount : decimal.Zero,
                        OnBehalfDonationAmount = priceInfo_V02 != null ? priceInfo_V02.OnBehalfDonationAmount : decimal.Zero,
                        OnBehalfDonationContact = priceInfo_V02 != null ? priceInfo_V02.OnBehalfDonationContact : string.Empty,
                        SelfDonationMemberId = priceInfo_V02 != null ? priceInfo_V02.SelfDonationMemberId : string.Empty,
                        OnBehalfDonationName = priceInfo_V02 != null ? priceInfo_V02.OnBehalfDonationName : string.Empty,
                        DiscountAmount = priceInfo_V02 != null ? priceInfo_V02.DiscountAmount : decimal.Zero,
                        FreightCharges = priceInfo_V02 != null && null != priceInfo_V02.ChargeList && priceInfo_V02.ChargeList.Any() ? GetFreightCharges(priceInfo_V02.ChargeList) : decimal.Zero,

                        OrderStatus = order.Status,
                        StoreInfo = order.StoreInfo,
                        WarehouseCode = ((order.Shipment as ShippingInfo_V01) == null) ? "" : (order.Shipment as ShippingInfo_V01).WarehouseCode,
                        ChannelInfo = order.ChannelInfo,
                        OrderMonth = order.OrderMonth,
                        IsCopyEnabled = order.ShoppingCartID > 0 ? copyEnabled : false, //If ShoppingCartID is 0 then CopyEnabled is set to false
                        OrderHeaderId = order.OrderHeaderID,
                        DistributorID = distributorId,
                        HasFeedBack = (order.HasFeedBack && !hasUnknownOrder),
                        CreatedBy = order.CreatedBy,
                        IsPaymentPending = pendingPayment,
                    };

                    var shippingAddress = order.Shipment as ShippingInfo_V01;

                    if (shippingAddress != null)
                    {
                        if (shippingAddress.Address != null)
                            orderView.Address = shippingAddress.Address.StateProvinceTerritory + shippingAddress.Address.CountyDistrict + shippingAddress.Address.City + shippingAddress.Address.Line1 + shippingAddress.Address.PostalCode;
                        orderView.AddressValue = ObjectMappingHelper.Instance.GetToShipping(shippingAddress.Address);
                        orderView.Recipient = shippingAddress.Recipient;
                        orderView.Phone = shippingAddress.Phone;
                        orderView.ShippingMethodId = shippingAddress.ShippingMethodID;
                    }

                    orderView.TotalAmount = (priceInfo.AmountDue + orderView.FreightCharges).ToString("00");

                    var createdBy = order.CreatedBy;
                    if (!string.IsNullOrWhiteSpace(createdBy))
                        orderView.IsHistoricalData = (createdBy.Trim().ToUpper() != "GDO");

                    cartItems = new List<MyHLProductItemView>();

                    if (order.OrderItems != null && order.OrderItems.Count > 0)
                    {
                        foreach (var itm in order.OrderItems)
                        {
                            if (string.IsNullOrEmpty(itm.SKU))
                                continue;

                            if (itm.SKU.EndsWith("||"))
                            {
                                itm.SKU = itm.SKU.Replace("||", ""); //a workaround to indicate this is preordering.
                                orderView.IsCopyEnabled = false;
                            }

                            if (itm is OnlineOrderItem)
                            {
                                var orderItem = itm as OnlineOrderItem;

                                if (orderItem != null)
                                {
                                    cartItems.Add(new MyHLProductItemView()
                                    {
                                        Quantity = orderItem.Quantity,
                                        SKU = string.IsNullOrEmpty(orderItem.SKU) ? "" : orderItem.SKU.Trim(),
                                        Description = orderItem.Description,
                                        RetailPrice = orderItem.RetailPrice
                                    });
                                }
                            }
                            else if (itm is OrderItem_V02)
                            {
                                var orderItem = itm as OrderItem_V02;

                                if (orderItem != null)
                                {
                                    cartItems.Add(new MyHLProductItemView()
                                    {
                                        Quantity = orderItem.Quantity,
                                        SKU = string.IsNullOrEmpty(orderItem.SKU) ? "" : orderItem.SKU.Trim(),
                                        Description = orderItem.Description,
                                        RetailPrice = orderItem.RetailPrice
                                    });
                                }
                            }
                        }
                    }

                    orderView.CartItems = cartItems;

                    if (IsChina)
                    {
                        var isAllVirtualOrder = IsAllVirtualOrder(orderView, virtualProduct);
                        orderView.IsCopyEnabled = isAllVirtualOrder ? false : orderView.IsCopyEnabled;

                        if (isAllVirtualOrder)
                        {
                            orderView.HasFeedBack = true; //Set this true so that the feedback button will not showing.
                        }
                    }

                    result.Add(orderView);
                }
            }

            // Search
            if (!string.IsNullOrWhiteSpace(filterExpressions))
                result = Search(result, filterExpressions);

            // Order Number
            if (!string.IsNullOrWhiteSpace(orderNumber))
                result = Search(result, orderNumber);

            // Sort
            if (string.IsNullOrWhiteSpace(sortExpressions))
                result = result.OrderByDescending(item => item.DateTimeForOrder).ToList();
            else
                result = ChinaDoSortBy(result, sortExpressions);

            if (Settings.GetRequiredAppSetting("GetOrderinfoCache", "true") == "true")
            {
                string cacheKey = string.Format(OrderListCaheKey + distributorId + "CN" + statusFilter + filterExpressions + sortExpressions + startOrderDate.ToString(YearMonthDayFormat) + endOrderDate.ToString(YearMonthDayFormat) + orderNumber);

                HttpRuntime.Cache.Insert(cacheKey,
                                             result,
                                             null,
                                             DateTime.Now.AddMinutes(Convert.ToDouble(Settings.GetRequiredAppSetting("GetOrderinfoCacheTimeout"))),
                                             Cache.NoSlidingExpiration,
                                             CacheItemPriority.Low,
                                             null);
            }

            return result;
        }
Example #4
0
        public List<MyHLShoppingCartView> GetPreOrders(string distributorId, int customerProfileID, string countryCode, DateTime? startOrderDate, DateTime? endOrderDate, MyHerbalife3.Ordering.Providers.China.PreOrderStatusFilterType statusFilter, string filterExpressions, string sortExpressions)
        {
            List<MyHLShoppingCartView> ret = new List<MyHLShoppingCartView>();

            #region date range...
            bool isStartDateDefined = (startOrderDate != null);
            bool isEndDateDefined = (endOrderDate != null);

            var sDate = !isStartDateDefined ? DateTime.Now.AddMonths(-1) : startOrderDate.Value;
            var eDate = !isEndDateDefined ? DateTime.Now.AddDays(2) : endOrderDate.Value;

            // if only one of them is undefined... adjust the other accordingly
            if ((!isStartDateDefined || !isEndDateDefined) && (isStartDateDefined != isEndDateDefined))
            {
                if (!isStartDateDefined) sDate = eDate.AddMonths(-1);
                if (!isEndDateDefined) eDate = sDate.AddMonths(1);
            }
            #endregion

            List<OnlineOrder> orderHeaderList = null;

            #region OrderHeader

            List<PreOrderImportStatusType> ordStsList = new List<PreOrderImportStatusType>();

            #region OrderStatusList
            switch (statusFilter)
            {
                case PreOrderStatusFilterType.Cancel_PreOrder:
                    ordStsList.Add(PreOrderImportStatusType.Cancel);
                    break;

                case PreOrderStatusFilterType.Hold_PreOrder:
                    ordStsList.Add(PreOrderImportStatusType.Hold);
                    break;

                case PreOrderStatusFilterType.ReadyToSubmit_PreOrder:
                    ordStsList.Add(PreOrderImportStatusType.ReadyToSubmit);
                    break;
            }
            #endregion

            if (ordStsList != null) // ordStsList.Count == 0 means all, so need to query
            {
                var req = new GetPreOrdersRequest_V01
                {
                    CustomerProfileID = customerProfileID,
                    OrderFilter = new PreOrdersFilter
                    {
                        DistributorId = distributorId,
                        StartDate = sDate,
                        EndDate = eDate,
                        OrderStatusList = ordStsList
                    },
                };

                if (_chinaOrderProxy == null)
                    _chinaOrderProxy = ServiceClientProvider.GetChinaOrderServiceProxy();

                var rsp = _chinaOrderProxy.GetPreOrders(new GetPreOrdersRequest1(req)).GetPreOrdersResult as GetPreOrdersResponse_V01;
                if (Helper.Instance.ValidateResponse(rsp))
                {
                    if (!IsChina)
                        orderHeaderList = rsp.Orders.Where(h => h.OrderCategory == OrderCategoryType.RSO).ToList();
                    else
                        orderHeaderList = rsp.Orders;
                }
                else
                    LoggerHelper.Error(string.Format("MyHLShoppingCartView.GetPreOrders() Error. Unsuccessful result from web service ChinaOrderSVC.GetPreOrders. Data: DistributorId={0}", distributorId));
            }

            #endregion

            #region orderHeaderList
            if (Helper.Instance.HasData(orderHeaderList))
            {
                foreach (var order in orderHeaderList)
                {
                    var priceInfo = order.Pricing as OrderTotals_V01;
                    var priceInfo_V02 = order.Pricing as OrderTotals_V02;
                    if (priceInfo == null) continue;
                    if (priceInfo.ItemsTotal <= 0) continue;

                    var orderView = new MyHLShoppingCartView
                    {
                        ID = order.ShoppingCartID.ToString(),
                        OrderNumber = order.OrderID ?? string.Empty,
                        Date = order.ReceivedDate.AddHours(8).ToString("d", CultureInfo.CurrentCulture),
                        DateTimeForOrder = order.ReceivedDate.AddHours(8),
                        TotalAmount = priceInfo.AmountDue.ToString("##.##"),
                        VolumePoints = priceInfo.VolumePoints.ToString("00.00"),

                        TotalAmountValue = priceInfo.AmountDue,
                        VolumePointsValue = priceInfo.VolumePoints,

                        ProductTaxTotal = priceInfo_V02 != null ? priceInfo_V02.ProductTaxTotal : decimal.Zero,
                        DonationAmount = priceInfo_V02 != null ? priceInfo_V02.Donation : decimal.Zero,
                        DiscountAmount = priceInfo_V02 != null ? priceInfo_V02.DiscountAmount : decimal.Zero,
                        FreightCharges = priceInfo_V02 != null && null != priceInfo_V02.ChargeList && priceInfo_V02.ChargeList.Any() ? GetFreightCharges(priceInfo_V02.ChargeList) : decimal.Zero,

                        OrderStatus = order.Status,
                        StoreInfo = order.StoreInfo,
                        ChannelInfo = order.ChannelInfo,
                        OrderMonth = order.OrderMonth,
                        OrderHeaderId = order.OrderHeaderID,
                        DistributorID = order.DistributorID,
                        HasFeedBack = order.HasFeedBack,
                        CreatedBy = order.CreatedBy,
                    };
                    orderView.TotalAmount = (priceInfo.AmountDue + orderView.FreightCharges).ToString("00");

                    LoadPreOrderDetails(orderView);

                    orderView.Address = ((ShippingInfo_V01)order.Shipment).Address.StateProvinceTerritory + ((ShippingInfo_V01)order.Shipment).Address.CountyDistrict + ((ShippingInfo_V01)order.Shipment).Address.City + ((ShippingInfo_V01)order.Shipment).Address.Line1 + ((ShippingInfo_V01)order.Shipment).Address.PostalCode;
                    orderView.AddressValue = ObjectMappingHelper.Instance.GetToShipping(((ShippingInfo_V01)order.Shipment).Address);
                    orderView.Recipient = ((ShippingInfo_V01)order.Shipment).Recipient;
                    orderView.Phone = ((ShippingInfo_V01)order.Shipment).Phone;
                    orderView.WarehouseCode = ((ShippingInfo_V01)order.Shipment).WarehouseCode;
                    orderView.ShippingMethodId = ((ShippingInfo_V01)order.Shipment).ShippingMethodID;

                    var createdBy = order.CreatedBy;
                    if (!string.IsNullOrWhiteSpace(createdBy))
                        orderView.IsHistoricalData = (createdBy.Trim().ToUpper() != "GDO");

                    ret.Add(orderView);
                }
            }
            #endregion

            // Search
            if (!string.IsNullOrWhiteSpace(filterExpressions))
                ret = Search(ret, filterExpressions);

            // Sort
            if (string.IsNullOrWhiteSpace(sortExpressions))
                ret = ret.OrderByDescending(item => item.OrderNumber).ToList();
            else
                ret = ChinaDoSortBy(ret, sortExpressions);

            return ret;
        }
Example #5
0
        /// <summary>
        /// Wrapp the given hl shopping cart to view.
        /// </summary>
        /// <param name="hlCarts">List of shopping cart.</param>
        /// <returns>Shopping cart views.</returns>
        public static List<MyHLShoppingCartView> WrappToShoppingCartViewList(List<MyHLShoppingCart> hlCarts, string Locale, string filterExpressions, string sortExpressions, bool savedCartsMode)
        {
            var config = HLConfigManager.Configurations.DOConfiguration;
            if (config.UseGregorianCalendar)
            {
                changeFormatCalendarToGregorian();
            }
            // Initializing the MyHLShoppingCartView list result.
            var cartViewList = new List<MyHLShoppingCartView>();
            if (hlCarts.Count > 1 && hlCarts[0].ShoppingCartID == hlCarts[1].ShoppingCartID && hlCarts[0].IsSavedCart)
            {
                // Leave the cart with the right date in list
                hlCarts.RemoveAt(0);
            }
            foreach (MyHLShoppingCart cart in hlCarts)
            {
                if (!cartViewList.Select(i => i.ID).Contains(cart.ShoppingCartID.ToString()) && cart.OrderCategory != ServiceProvider.CatalogSvc.OrderCategoryType.APF)
                {
                    var cartView = new MyHLShoppingCartView();

                    // Direct properties.
                    cartView.ID = cart.ShoppingCartID.ToString();
                    cartView.OrderNumber = cart.OrderNumber ?? string.Empty;
                    cartView.DraftName = cart.CartName ?? string.Empty;

                    if (savedCartsMode)
                    {
                        cartView.Date = cart.LastUpdated.ToString("d", CultureInfo.CurrentCulture);
                        cartView.LastUpdatedDate = cart.LastUpdated;
                    }
                    else
                    {
                        cartView.Date = cart.OrderDate.ToString("d", CultureInfo.CurrentCulture);
                        cartView.LastUpdatedDate = cart.OrderDate;
                    }

                    var deliveryOpt = cart.DeliveryOption;

                    // Address formatting
                    if (savedCartsMode)
                    {
                        cart.LoadShippingInfo(cart.DeliveryOptionID, cart.ShippingAddressID, cart.DeliveryOption, true);
                    }
                    else
                    {
                        if (cart.DeliveryInfo == null || cart.DeliveryInfo.Address == null)
                        {
                            cart.GetShippingInfoForCopyOrder(cart.DistributorID, cart.Locale, cart.ShoppingCartID, deliveryOpt, true);
                        }
                    }

                    cartView.Recipient = cart.DeliveryInfo != null && cart.DeliveryInfo.Address != null ?
                        cart.DeliveryInfo.Address.Recipient ?? string.Empty : string.Empty;
                    if (cart.DeliveryInfo != null && cart.DeliveryInfo.Address != null)
                    {
                        cartView.Address =
                            ShippingProvider.GetShippingProvider(Locale.Substring(3, 2)).FormatShippingAddress(
                                new DeliveryOption(cart.DeliveryInfo.Address),
                                cart.DeliveryInfo.Option, cart.DeliveryInfo.Description, false) ?? string.Empty;
                        cartView.AddressValue = cart.DeliveryInfo.Address.Address;
                    }

                    if (!savedCartsMode && deliveryOpt == ServiceProvider.CatalogSvc.DeliveryOptionType.Pickup && cart.DeliveryInfo != null && cart.DeliveryInfo.Address != null)
                    {
                        cartView.Address = string.Concat(cart.DeliveryInfo.Address.Alias, "</br>", cartView.Address);
                        cartView.AddressValue = cart.DeliveryInfo.Address.Address;
                    }

                    cartViewList.Add(cartView);

                    // Getting car items
                    var cartItems = new List<MyHLProductItemView>();

                    if (cart.CartItems != null)
                    {
                        cart.CartItems.ForEach(
                            item =>
                            cartItems.Add(new MyHLProductItemView() { Quantity = item.Quantity, SKU = item.SKU }));

                        // Getting descriptions
                        if (savedCartsMode)
                        {
                            cart.GetShoppingCartForDisplay(false, true);
                        }

                        if (cart.ShoppingCartItems != null && cart.ShoppingCartItems.Count() > 0)
                        {
                            foreach (MyHLProductItemView t in cartItems)
                            {
                                if (t != null)
                                {
                                    var item = cart.ShoppingCartItems.Where(x => x.SKU == t.SKU);
                                    if (item.Count() > 0)
                                    {
                                        t.Description = item.FirstOrDefault().Description;
                                    }
                                }
                            }
                        }
                    }

                    cartView.CartItems = cartItems;
                }
            }

            // Search
            if (!string.IsNullOrEmpty(filterExpressions))
            {
                cartViewList = Search(cartViewList, filterExpressions);
            }
            // Sort
            if (!string.IsNullOrEmpty(sortExpressions))
            {
                cartViewList = SortBy(cartViewList, sortExpressions);
            }

            return cartViewList;
        }