Example #1
0
 private Guid?GetUsedCouponCodeForMultiCouponCodeDiscount(Discount discount)
 {
     if (discount.CouponCodeType != CouponCodeType.Multi)
     {
         return(null);
     }
     return(discount.CouponCodes.First(x =>
                                       _currentUserService.GetUsedCouponCodeUsages().Select(c => c.Code).Contains(x.Code)).Id);
 }
        public LiquidAdapter GetCurrentUserCartModel()
        {
            _shoppingCartHelper.HandleUserCartWarnings(_workContext.CurrentUser);

            foreach (var item in _workContext.CurrentUser.ShoppingCartItems)
            {
                item.Product.Pictures = item.Product.Pictures.OrderBy(x => x.DisplayOrder).ToList();
            }
            var shoppingCartItemIds = _workContext.CurrentUser.ShoppingCartItems.Select(x => x.Product.Id)
                                      .ToList();

            return(new UserCartLiquidViewModel
            {
                User = _workContext.CurrentUser.AsLiquidAdapted(),
                ShoppingCartItems = _workContext.CurrentUser.ShoppingCartItems.MapToLiquidVeiwModel(),
                CrossSellings = GetProductCrossSellings(shoppingCartItemIds),
                Eshantions = GetProductEshantions(shoppingCartItemIds),
                TotalPrice = _workContext.CurrentUser.ShoppingCartItems.Select(x => x.Product).Sum(x => x.Price),
                CouponCodeUsages = _currentUserService.GetUsedCouponCodeUsages()
            });
        }