/// <summary> /// Gets the displayable items for a basket /// </summary> /// <param name="basket">the basket</param> /// <param name="includeShipping">whether or not to include shipping charges in displayed items list</param> /// <param name="alwaysIncludeTaxes">if true forces taxes to be included in the displayed items list even if /// the shopping display is not configured to display them</param> /// <returns>the displayable items for the basket</returns> public static IList <BasketItem> GetDisplayItems(Basket basket, bool includeShipping, bool alwaysIncludeTaxes = false) { // ADD STANDARD DISPLAY ITEMS IList <BasketItem> displayedBasketItems = new List <BasketItem>(); foreach (BasketItem item in basket.Items) { if (DisplayBasketItem(item, includeShipping)) { displayedBasketItems.Add(item); } } // ADD IN TAX ITEMS IF SPECIFIED FOR DISPLAY if (alwaysIncludeTaxes || TaxHelper.GetEffectiveShoppingDisplay(basket.User) == TaxShoppingDisplay.LineItem) { // TAXES SHOULD BE SHOWN foreach (BasketItem item in basket.Items.Where(bi => bi.OrderItemType == OrderItemType.Tax)) { displayedBasketItems.Add(item); if (AbleContext.Current.User.IsAnonymous && !AbleContext.Current.User.PrimaryAddress.IsValid) { item.Name = "<span class=\"item\">" + item.Name + " (estimated)</span>"; } } } // SORT ITEMS, THEN COMBINE ORDER COUPON ITEMS FOR DISPLAY displayedBasketItems.Sort(new BasketItemComparer()); displayedBasketItems = displayedBasketItems.CombineOrderCoupons(); return(displayedBasketItems); }
private IList <BasketItem> GetBasketItems() { User user = AbleContext.Current.User; Basket basket = user.Basket; IBasketService preCheckoutService = AbleContext.Resolve <IBasketService>(); preCheckoutService.Combine(basket); _DisplayedBasketItems = new List <BasketItem>(); foreach (BasketItem item in basket.Items) { if (Array.IndexOf(displayItemTypes, item.OrderItemType) > -1) { if (item.OrderItemType == OrderItemType.Product && item.IsChildItem) { // WHETHER THE CHILD ITEM DISPLAYS DEPENDS ON THE ROOT BasketItem rootItem = item.GetParentItem(true); if (rootItem != null && rootItem.Product != null && rootItem.Product.Kit != null && rootItem.Product.Kit.ItemizeDisplay) { // ITEMIZED DISPLAY ENABLED, SHOW THIS CHILD ITEM _DisplayedBasketItems.Add(item); } } else { // NO ADDITIONAL CHECK REQUIRED TO INCLUDE ROOT PRODUCTS OR NON-PRODUCTS _DisplayedBasketItems.Add(item); } } } // ADD IN ANY CHILD ITEMS //ADD IN TAX ITEMS IF SPECIFIED FOR DISPLAY if (TaxHelper.GetEffectiveShoppingDisplay(user) == TaxShoppingDisplay.LineItem) { foreach (BasketItem item in basket.Items) { //IS THIS A TAX ITEM? if (item.OrderItemType == OrderItemType.Tax) { ////IS THE TAX ITEM A PARENT ITEM OR A CHILD OF A DISPLAYED ITEM? //if (!item.IsChildItem || (_DisplayedBasketItems.IndexOf(item.ParentItemId) > -1)) //{ //TAX SHOULD BE SHOWN _DisplayedBasketItems.Add(item); //} } } } // COMBINE ORDER COUPON ITEMS _DisplayedBasketItems = _DisplayedBasketItems.CombineOrderCoupons(); //SORT ITEMS TO COMPLETE INTITIALIZATION _DisplayedBasketItems.Sort(new BasketItemComparer()); return(_DisplayedBasketItems); }
private bool GetShowTaxLineItems() { TaxShoppingDisplay displaySetting = TaxHelper.GetEffectiveShoppingDisplay(AbleContext.Current.User); return(displaySetting == TaxShoppingDisplay.LineItem); }