private async Task <ShoppingCartLinksModel> PrepareShoppingCartLinks() { var shoppingCartTypes = new List <ShoppingCartType>(); shoppingCartTypes.Add(ShoppingCartType.ShoppingCart); shoppingCartTypes.Add(ShoppingCartType.Auctions); if (_shoppingCartSettings.AllowOnHoldCart) { shoppingCartTypes.Add(ShoppingCartType.OnHoldCart); } var model = new ShoppingCartLinksModel { ShoppingCartEnabled = await _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = await _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), MiniShoppingCartEnabled = _shoppingCartSettings.MiniShoppingCartEnabled, ShoppingCartItems = _workContext.CurrentCustomer.ShoppingCartItems.Any() ? _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => shoppingCartTypes.Contains(sci.ShoppingCartType)) .LimitPerStore(_shoppingCartSettings.CartsSharedBetweenStores, _storeContext.CurrentStore.Id) .Sum(x => x.Quantity) : 0, WishlistItems = _workContext.CurrentCustomer.ShoppingCartItems.Any() ? _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist) .LimitPerStore(_shoppingCartSettings.CartsSharedBetweenStores, _storeContext.CurrentStore.Id) .Sum(x => x.Quantity) : 0 }; return(model); }
private async Task <ShoppingCartLinksModel> PrepareShoppingCartLinks() { var model = new ShoppingCartLinksModel { ShoppingCartEnabled = await _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = await _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), MiniShoppingCartEnabled = _shoppingCartSettings.MiniShoppingCartEnabled, //performance optimization (use "HasShoppingCartItems" property) ShoppingCartItems = _workContext.CurrentCustomer.ShoppingCartItems.Any() ? _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart || sci.ShoppingCartType == ShoppingCartType.Auctions) .LimitPerStore(_shoppingCartSettings.CartsSharedBetweenStores, _storeContext.CurrentStore.Id) .Sum(x => x.Quantity) : 0, WishlistItems = _workContext.CurrentCustomer.ShoppingCartItems.Any() ? _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist) .LimitPerStore(_shoppingCartSettings.CartsSharedBetweenStores, _storeContext.CurrentStore.Id) .Sum(x => x.Quantity) : 0 }; return(model); }