예제 #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;
            }
        }
예제 #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                CartInfo myCart = Controller.GetCart(PortalSettings.PortalId, CartId);
                if (myCart != null)
                {
                    List <CartProductInfo> myProducts = _controller.GetCartProducts(CartId);

                    TemplateControl tp = LoadControl("controls/TemplateControl.ascx") as TemplateControl;
                    tp.Key = "MiniCart";
                    string template = tp.GetTemplate((string)Settings["Template"]);

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

                    Hashtable storeSettings = _controller.GetStoreSettings(PortalSettings.PortalId);
                    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;
                    }
                    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;
                }
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }