private void BindBasket(Basket basket) { //GET LIST OF PRODUCTS IList <BasketItem> _Products = new List <BasketItem>(); decimal _ProductTotal = 0; decimal _DiscountTotal = 0; decimal _ShippingTotal = 0; decimal _TaxesTotal = 0; decimal _CouponsTotal = 0; decimal _OtherTotal = 0; decimal _GrandTotal = 0; // MAKE SURE ITEMS ARE PROPERTY SORTED BEFORE DISPLAY basket.Items.Sort(new BasketItemComparer()); foreach (BasketItem item in basket.Items) { switch (item.OrderItemType) { case OrderItemType.Product: if (!item.IsChildItem) { // ROOT LEVEL ITEMS GET ADDED _Products.Add(item); _ProductTotal += GetItemShopPrice(item); } else { 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 _Products.Add(item); _ProductTotal += GetItemShopPrice(item); } } break; case OrderItemType.Discount: _DiscountTotal += GetItemShopPrice(item); break; case OrderItemType.Shipping: case OrderItemType.Handling: _ShippingTotal += GetItemShopPrice(item); break; case OrderItemType.Tax: _TaxesTotal += item.ExtendedPrice; break; case OrderItemType.Coupon: _CouponsTotal += item.ExtendedPrice; break; default: _OtherTotal += item.ExtendedPrice; break; } _GrandTotal += item.ExtendedPrice; } //BIND BASKET ITEMS BasketRepeater.DataSource = _Products; BasketRepeater.DataBind(); if (_DiscountTotal != 0) { trDiscounts.Visible = true; Discounts.Text = _DiscountTotal.LSCurrencyFormat("ulc"); } if (_ShippingTotal != 0) { trShipping.Visible = true; Shipping.Text = _ShippingTotal.LSCurrencyFormat("ulc"); } if (_TaxesTotal != 0) { trTaxes.Visible = true; Taxes.Text = _TaxesTotal.LSCurrencyFormat("lc"); } if (_CouponsTotal != 0) { trCoupons.Visible = true; Coupons.Text = _CouponsTotal.LSCurrencyFormat("lc"); } if (_OtherTotal != 0) { trOther.Visible = true; Other.Text = _OtherTotal.LSCurrencyFormat("lc"); } Total.Text = _GrandTotal.LSCurrencyFormat("lc"); EditOrderLink.NavigateUrl += "?UID=" + basket.UserId; }
private void BindBasket(Basket basket) { //GET LIST OF PRODUCTS IList <BasketItem> _Products = new List <BasketItem>(); decimal _ProductTotal = 0; decimal _DiscountTotal = 0; bool showTaxLineItems = GetShowTaxLineItems(); // MAKE SURE ITEMS ARE PROPERTY SORTED BEFORE DISPLAY basket.Items.Sort(new BasketItemComparer()); foreach (BasketItem item in basket.Items) { if (item.OrderItemType == OrderItemType.Product) { if (!item.IsChildItem) { // ROOT LEVEL ITEMS GET ADDED _Products.Add(item); _ProductTotal += TaxHelper.GetShopExtendedPrice(basket, item); } else { 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 _Products.Add(item); _ProductTotal += TaxHelper.GetShopExtendedPrice(basket, item); } } } else if (item.OrderItemType == OrderItemType.Discount) { _DiscountTotal += TaxHelper.GetShopExtendedPrice(basket, item); } else if (item.OrderItemType == OrderItemType.Tax && showTaxLineItems && AbleContext.Current.User.IsAnonymous && !AbleContext.Current.User.PrimaryAddress.IsValid) { _Products.Add(item); item.Name = "<span class=\"label\">" + item.Name + " (estimated)</span>"; } else if (item.OrderItemType == OrderItemType.Tax && showTaxLineItems) { _Products.Add(item); } } if (_Products.Count > 0) { //BIND BASKET ITEMS BasketRepeater.DataSource = _Products; BasketRepeater.DataBind(); if (_DiscountTotal != 0) { Discounts.Text = _DiscountTotal.LSCurrencyFormat("ulc"); DiscountsPanel.Visible = true; } else { DiscountsPanel.Visible = false; } Discounts.Text = _DiscountTotal.LSCurrencyFormat("ulc"); SubTotal.Text = (_ProductTotal + _DiscountTotal).LSCurrencyFormat("ulc"); //UPDATE CHECKOUT LINK //CheckoutLink.NavigateUrl = AbleCommerce.Code.NavigationHelper.GetCheckoutUrl(); ShowBasket(true); } else { ShowBasket(false); } }