Esempio n. 1
0
        private void ShowMiniCart()
        {
            _controller = new BBStoreController();

            CartInfo myCart = _controller.GetCart(PortalSettings.PortalId, CartId);

            if (myCart != null)
            {
                List <CartProductInfo> myProducts = _controller.GetCartProducts(CartId);

                ModuleController objModules = new ModuleController();
                ModuleInfo       cartModule = objModules.GetModuleByDefinition(PortalSettings.PortalId, "BBStore Cart");

                Hashtable storeSettings = _controller.GetStoreSettings(PortalSettings.PortalId);

                string template = _itemTemplate;

                if (!String.IsNullOrEmpty((string)storeSettings["MiniCartTemplate"]))
                {
                    template = (string)storeSettings["MiniCartTemplate"];
                }

                bool hideIfEmpty = Convert.ToBoolean(storeSettings["HideMiniCartIfEmpty"] ?? "false");

                bool    showNetPrice = (storeSettings["ShowNetpriceInCart"].ToString() == "0");
                decimal total        = myCart.OrderTotal + myCart.AdditionalTotal;

                if (showNetPrice == false)
                {
                    total += myCart.OrderTax + myCart.AdditionalTax;
                }

                decimal productCount = 0;
                foreach (CartProductInfo cp in myProducts)
                {
                    productCount += cp.Quantity;
                }

                if (hideIfEmpty && total <= 0)
                {
                    template = "";
                }
                else
                {
                    template = template.Replace("[PRODUCTS]", productCount.ToString("f0"));
                    template = template.Replace("[TOTAL]", total.ToString("f2"));
                    template = template.Replace("[CURRENCY]", myCart.Currency);
                    template = template.Replace("[CARTLINK]", (cartModule == null ? "" : Globals.NavigateURL(cartModule.TabID)));
                    template = template.Replace("[CHECKOUTLINK]", (cartModule == null ? "" : Globals.NavigateURL(cartModule.TabID, "", "action=checkout")));
                }
                ltrMiniCart.Text = template;
            }
        }