Пример #1
0
 public void ConvertToCart(Boolean debugMode = false, String storageType = "Cookie", string nameAppendix = "")
 {
     // only magers and editors allowed to edit orders
     if (UserController.Instance.GetCurrentUserInfo().IsInRole(StoreSettings.ManagerRole) ||
         UserController.Instance.GetCurrentUserInfo().IsInRole(StoreSettings.EditorRole) ||
         UserController.Instance.GetCurrentUserInfo().IsInRole("Administrators"))
     {
         AddAuditMessage("EDIT ORDER", "sys", UserController.Instance.GetCurrentUserInfo().Username, "False");
         PurchaseTypeCode = "CART";
         EditMode         = "E";
         var cartId   = base.SavePurchaseData();
         var cartData = new CartData(PortalId, "", cartId.ToString(""));              //create the client record (cookie)
         cartData.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartlist"); // make sure we start edit at cart stage.
         cartData.Save();
         if (StoreSettings.Current.DebugModeFileOut)
         {
             OutputDebugFile("debug_convertedorder.xml");
         }
     }
 }
Пример #2
0
        public void CopyToCart(Boolean debugMode = false, String storageType = "Cookie", string nameAppendix = "")
        {
            PurchaseTypeCode = "CART";
            EditMode         = "R";

            // reset order fields
            ShippedDate     = "";
            OrderStatus     = "010";
            TrackingCode    = "";
            InvoiceFileExt  = "";
            InvoiceFileName = "";
            InvoiceFilePath = "";
            PurchaseInfo.SetXmlProperty("genxml/audit", "");

            var cartId   = base.SavePurchaseData(true);
            var cartData = new CartData(PortalId, "", cartId.ToString(""));  //create the client record (cookie)

            cartData.Save();
            if (StoreSettings.Current.DebugModeFileOut)
            {
                OutputDebugFile("debug_copytocart.xml");
            }
        }
Пример #3
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];
            var navigationData = new NavigationData(PortalId, "ClientsAdmin");

            switch (e.CommandName.ToLower())
            {
                case "entrydetail":
                    param[0] = "uid=" + cArg;
                    if (_page != "") param[1] = "page=" + _page;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "return":
                    param[0] = "";
                    if (_page != "") param[1] = "page=" + _page;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "search":
                    navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch,"","");
                    navigationData.Save();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "unlockuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.UnlockUser();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "deleteuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.DeleteUser();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "removeuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        var ok = clientData.RemoveUser();
                        if (!ok)
                        {
                            NBrightBuyUtils.SetNotfiyMessage(ModuleId,"removeuser", NotifyCode.fail);
                            param[0] = "uid=" + cArg;
                        }
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "validateuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.AuthoriseClient();
                        clientData.AddClientRole(ModSettings);
                        if (StoreSettings.Current.Get("resetpasswordonclientvalidate") == "True") clientData.ResetPassword();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetpass":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.ResetPassword();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "viewaddressbook":
                    param[0] = "";
                    if (Utils.IsNumeric(cArg))
                    {
                        param[0] = "ctrl=addressbook";
                        param[1] = "uid=" + cArg;
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "vieworders":
                    param[0] = "";
                    if (Utils.IsNumeric(cArg))
                    {
                        param[0] = "ctrl=orders";
                        param[1] = "uid=" + cArg;
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "createorder":
                    param[0] = "";
                    var tabId = TabId;
                    if (Utils.IsNumeric(cArg))
                    {
                        var cart = new CartData(PortalId);
                        cart.UserId = Convert.ToInt32(cArg);
                        cart.EditMode = "C";
                        cart.Save();
                        tabId = StoreSettings.Current.GetInt("productlisttab");
                        if (tabId==0) tabId = TabId;
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(tabId, param), true);
                    break;
                case "save":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        if (clientData.Exists)
                        {
                            clientData.Update(rpData);
                            clientData.Save();
                        }
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
            }
        }
Пример #4
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var rtnTabId = TabId;
            var param = new string[4];

            if (_guidkey != "")
                param[0] = "ref=" + _guidkey; //using ref is url
            else
                if (_eid != "") param[0] = "eid=" + _eid; // using id in url

            if (_modkey != "") param[1] = "modkey=" + _modkey;

            if (_catname != "")
                param[2] = "catref=" + _catname; //using ref is url
            else
                if (_catid != "") param[2] = "catid=" + _catid; //using id is url

            // redirect to cart after add to basket is arg is redirect
            if (cArg.ToLower() == "redirect" && Utils.IsNumeric(StoreSettings.Current.CartTabId)) rtnTabId = StoreSettings.Current.CartTabId;
            if (cArg.ToLower() == "redirectnoparam" && Utils.IsNumeric(StoreSettings.Current.CartTabId))
            {
                rtnTabId = StoreSettings.Current.CartTabId;
                param[0] = "";
                param[1] = "";
                param[2] = "";
            }

            switch (e.CommandName.ToLower())
            {
                case "addtobasket":
                    var currentcart = new CartData(PortalId);
                    currentcart.AddItem(rpData, StoreSettings.Current.SettingsInfo, e.Item.ItemIndex, DebugMode);
                    currentcart.Save(StoreSettings.Current.DebugMode);
                    param[3] = "addcart=1";
                    Response.Redirect(Globals.NavigateURL(rtnTabId, "", param), true);
                    break;
                case "addalltobasket":
                    var currentcart2 = new CartData(PortalId);
                    foreach (RepeaterItem ri in rpData.Items)
                    {
                        currentcart2.AddItem(rpData, StoreSettings.Current.SettingsInfo, ri.ItemIndex, DebugMode);
                    }
                    currentcart2.Save(StoreSettings.Current.DebugMode);
                    param[3] = "addcart=1";
                    Response.Redirect(Globals.NavigateURL(rtnTabId, "", param), true);
                    break;
                case "addcookietobasket":
                    var currentcart3 = new CartData(PortalId);
                    currentcart3.AddCookieToCart();
                    currentcart3.Save(StoreSettings.Current.DebugMode);
                    param[3] = "addcart=1";
                    Response.Redirect(Globals.NavigateURL(rtnTabId, "", param), true);
                    break;
                case "docdownload":
                    var s = cArg.Split(':');
                    if (s.Length == 2)
                    {
                        var itemid = s[0];
                        var idx = s[1];
                        if (Utils.IsNumeric(idx) && Utils.IsNumeric(itemid))
                        {
                            var index = Convert.ToInt32(idx);
                            var prdData = ProductUtils.GetProductData(Convert.ToInt32(itemid), Utils.GetCurrentCulture());
                            if (prdData.Docs.Count >= index)
                            {
                                var docInfo = prdData.Docs[index -1];
                                var docFilePath = docInfo.GetXmlProperty("genxml/hidden/filepath");
                                var fileName = docInfo.GetXmlProperty("genxml/textbox/txtfilename"); ;
                                var fileExt = docInfo.GetXmlProperty("genxml/hidden/fileext");
                                var purchase = docInfo.GetXmlProperty("genxml/checkbox/chkpurchase");

                                if (fileName == "") fileName = "filename";
                                if (!fileName.EndsWith(fileExt)) fileName += fileExt;

                                if (purchase == "True")
                                {
                                    //[TODO: check if the document has been purchased]
                                    Utils.ForceDocDownload(docFilePath, fileName, Response);
                                }
                                else
                                {
                                    Utils.ForceDocDownload(docFilePath, fileName, Response);
                                }
                            }
                        }

                    }
                    break;
                case "printproduct":
                    param[0] = "eid=" + _eid;
                    param[1] = "print=printproduct";
                    param[2] = "template=printproduct.html";
                    Response.Redirect(Globals.NavigateURL(TabId,"", param), true);
                    break;
                default :
                    //check for any command providers.
                    var providerList = NBrightCore.providers.GenXProviderManager.ProviderList;
                    if (providerList != null)
                    {
                        foreach (var prov in providerList)
                        {
                            prov.Value.CtrlItemCommand(source, e);
                        }
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
            }
        }
Пример #5
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // get setting via control params
            if (DisplayHeader != null && DisplayHeader == "") DisplayHeader = "minicartheader.html";
            if (DisplayBody != null && DisplayHeader == "") DisplayBody = "minicartbody.html";
            if (DisplayFooter != null && DisplayHeader == "") DisplayFooter = "minicartfooter.html";
            if (!String.IsNullOrEmpty(DisplayHeader) && !ModSettings.Settings().ContainsKey("txtdisplayheader")) ModSettings.Settings().Add("txtdisplayheader", DisplayHeader);
            if (!String.IsNullOrEmpty(DisplayBody) && !ModSettings.Settings().ContainsKey("txtdisplaybody")) ModSettings.Settings().Add("txtdisplaybody", DisplayBody);
            if (!String.IsNullOrEmpty(DisplayFooter) && !ModSettings.Settings().ContainsKey("txtdisplayfooter")) ModSettings.Settings().Add("txtdisplayfooter", DisplayFooter);
            if (!String.IsNullOrEmpty(PaymentTab) && !ModSettings.Settings().ContainsKey("PaymentTab")) ModSettings.Settings().Add("PaymentTab",PaymentTab );
            if (!String.IsNullOrEmpty(Themefolder) && !ModSettings.Settings().ContainsKey("themefolder")) ModSettings.Settings().Add("themefolder", Themefolder);

            _cartInfo = new CartData(PortalId);

            _addressData = new AddressData(_cartInfo.UserId.ToString(""));

            if (ModSettings.Get("themefolder") == "")  // if we don't have module setting jump out
            {
                rpDataH.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            try
            {
                _templH = ModSettings.Get("txtdisplayheader");
                _templD = ModSettings.Get("txtdisplaybody");
                _templDfoot = ModSettings.Get("txtdisplaybodyfoot");
                _templF = ModSettings.Get("txtdisplayfooter");

                const string templAB = "cartbillingaddress.html";
                const string templAS = "cartshippingaddress.html";
                const string templS = "cartshipment.html";
                const string templE = "cartextra.html";
                const string templD = "cartdetails.html";

                carttype = ModSettings.Get("ddlcarttype");  // This is left for backward compatiblity with NBS_Cart module (now removed from install).

                if (carttype == "")
                {
                    // cart type is not a setting, so use the controlanme
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_MiniCart") carttype = "1";
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_FullCart") carttype = "3";
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_Checkout") carttype = "2";
                }

                if (carttype == "3" || carttype == "2") // check if we need to add cookie items
                {
                    _cartInfo.AddCookieToCart();
                    _cartInfo.Save();
                }
                if (!_cartInfo.GetCartItemList().Any() && (carttype == "3" || carttype == "2"))
                    _templH = "cartempty.html"; // check for empty cart
                else
                {
                    // Get Display Body
                    var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                    rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                    // Get Display Footer
                    var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);
                    rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                    // Get CartLayout
                    var layouttemplate = "checkoutlayout.html";
                    if (carttype == "3") layouttemplate = "fullcartlayout.html";
                    var checkoutlayoutTempl = ModCtrl.GetTemplateData(ModSettings, layouttemplate, Utils.GetCurrentCulture(), DebugMode);
                    checkoutlayout.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(checkoutlayoutTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    _templateHeader = (GenXmlTemplate)checkoutlayout.ItemTemplate;

                }
                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

                if (carttype == "2")
                {
                    // add any shiiping provider templates to the cart layout, so we can process any data required by them
                    rpShip.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templS, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    rpAddrB.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templAB, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    rpAddrS.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templAS, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);

                    var checkoutextraTempl = ModCtrl.GetTemplateData(ModSettings, templE, Utils.GetCurrentCulture(), DebugMode);
                    checkoutextraTempl += GetShippingProviderTemplates();
                    rpExtra.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(checkoutextraTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                }

            }
            catch (Exception exc)
            {
                rpDataF.ItemTemplate = new GenXmlTemplate(exc.Message, ModSettings.Settings());
                // catch any error and allow processing to continue, output error as footer template.
            }
        }
Пример #6
0
        public void CopyToCart(Boolean debugMode = false, String storageType = "Cookie", string nameAppendix = "")
        {
            PurchaseTypeCode = "CART";
            EditMode = "R";

            // reset order fields
            ShippedDate = "";
            OrderStatus = "010";
            TrackingCode = "";
            InvoiceFileExt = "";
            InvoiceFileName = "";
            InvoiceFilePath = "";
            PurchaseInfo.SetXmlProperty("genxml/audit","");
            OrderNumber = "";

            var cartId = base.SavePurchaseData(true);
            var cartData = new CartData(PortalId,  "", cartId.ToString("")); //create the client record (cookie)

            cartData.Save();
            if (StoreSettings.Current.DebugModeFileOut) OutputDebugFile("debug_copytocart.xml");
        }
Пример #7
0
 public void ConvertToCart(Boolean debugMode = false, String storageType = "Cookie", string nameAppendix = "")
 {
     // only magers and editors allowed to edit orders
     if (UserController.Instance.GetCurrentUserInfo().IsInRole(StoreSettings.ManagerRole) ||
         UserController.Instance.GetCurrentUserInfo().IsInRole(StoreSettings.EditorRole) ||
         UserController.Instance.GetCurrentUserInfo().IsInRole("Administrators"))
     {
         AddAuditMessage("EDIT ORDER","sys",UserController.Instance.GetCurrentUserInfo().Username,"False");
         PurchaseTypeCode = "CART";
         EditMode = "E";
         var cartId = base.SavePurchaseData();
         var cartData = new CartData(PortalId, "", cartId.ToString("")); //create the client record (cookie)
         cartData.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartlist"); // make sure we start edit at cart stage.
         cartData.Save();
         if (StoreSettings.Current.DebugModeFileOut) OutputDebugFile("debug_convertedorder.xml");
     }
 }
Пример #8
0
        private string AddToBasket(HttpContext context)
        {
            try
            {
                var strOut = "";
                var ajaxInfo = GetAjaxInfo(context);
                var settings = ajaxInfo.ToDictionary();

                if (settings.ContainsKey("productid"))
                {
                    if (!settings.ContainsKey("portalid")) settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings

                    var currentcart = new CartData(Convert.ToInt16(settings["portalid"]));
                    currentcart.AddAjaxItem(ajaxInfo, StoreSettings.Current.SettingsInfo,StoreSettings.Current.DebugMode);
                    currentcart.Save(StoreSettings.Current.DebugMode);
                    strOut = "OK";
                }

                return strOut;
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
Пример #9
0
        private String RenderCart(HttpContext context)
        {
            var ajaxInfo = GetAjaxInfo(context);
            var carttemplate = ajaxInfo.GetXmlProperty("genxml/hidden/carttemplate");
            if (carttemplate == "") carttemplate = ajaxInfo.GetXmlProperty("genxml/hidden/minicarttemplate");
            var theme = ajaxInfo.GetXmlProperty("genxml/hidden/carttheme");
            if (theme == "") theme = ajaxInfo.GetXmlProperty("genxml/hidden/minicarttheme");
            var lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang");
            var controlpath = ajaxInfo.GetXmlProperty("genxml/hidden/controlpath");
            if (controlpath == "") controlpath = "/DesktopModules/NBright/NBrightBuy";
            var razorTempl = "";
            if (carttemplate != "")
            {
                if (lang == "") lang = Utils.GetCurrentCulture();
                var currentcart = new CartData(PortalSettings.Current.PortalId);
                if (UserController.Instance.GetCurrentUserInfo().UserID != -1)  // If we have a user, do save to update userid, so addrees checkout can get addresses.
                {
                    if (currentcart.UserId != UserController.Instance.GetCurrentUserInfo().UserID && currentcart.EditMode == "")
                    {
                        currentcart.Save();
                    }
                }

                razorTempl = NBrightBuyUtils.RazorTemplRender(carttemplate, 0,"", currentcart, controlpath, theme, lang, StoreSettings.Current.Settings());
            }
            return razorTempl;
        }
Пример #10
0
        private string UpdateCartAddress(HttpContext context,String addresstype = "")
        {
            var currentcart = new CartData(PortalSettings.Current.PortalId);
                var ajaxInfo = GetAjaxInfo(context,true);

                currentcart.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartsummary"); // (Legacy) we need to set this so the cart calcs shipping

                if (addresstype == "bill")
                {
                    currentcart.AddBillingAddress(ajaxInfo);
                    currentcart.Save();
                }

                if (addresstype == "ship")
                {
                    if (currentcart.GetShippingOption() == "2") // need to test this, becuase in legacy code the shipping option is set to "2" when we save the shipping address.
                    {
                        currentcart.AddShippingAddress(ajaxInfo);
                        currentcart.Save();
                    }
                }

                if (addresstype == "shipoption")
                {
                    var shipoption = ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/rblshippingoptions");
                    currentcart.SetShippingOption(shipoption);
                    currentcart.Save();
                }

                return addresstype;
        }
Пример #11
0
 private string RemoveFromCart(HttpContext context)
 {
     var ajaxInfo = GetAjaxInfo(context);
         var currentcart = new CartData(PortalSettings.Current.PortalId);
         currentcart.RemoveItem(ajaxInfo.GetXmlProperty("genxml/hidden/itemcode"));
         currentcart.Save(StoreSettings.Current.DebugMode);
         return "OK";
 }
Пример #12
0
        private string RedirectToPayment(HttpContext context)
        {
            try
            {
                RecalculateSummary(context);

                var currentcart = new CartData(PortalSettings.Current.PortalId);

                if (currentcart.GetCartItemList().Count > 0)
                {
                    currentcart.SetValidated(true);
                    if (currentcart.EditMode == "E") currentcart.ConvertToOrder();
                }
                else
                {
                    currentcart.SetValidated(true);
                }
                currentcart.Save();

                var rtnurl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId);
                if (currentcart.EditMode == "E")
                {
                    // is order being edited, so return to order status after edit.
                    // ONLY if the cartsummry is being displayed to the manager.
                    currentcart.ConvertToOrder();
                    // redirect to back office
                    var param = new string[2];
                    param[0] = "ctrl=orders";
                    param[1] = "eid=" + currentcart.PurchaseInfo.ItemID.ToString("");
                    var strbackofficeTabId = StoreSettings.Current.Get("backofficetabid");
                    var backofficeTabId = PortalSettings.Current.ActiveTab.TabID;
                    if (Utils.IsNumeric(strbackofficeTabId)) backofficeTabId = Convert.ToInt32(strbackofficeTabId);
                    rtnurl = Globals.NavigateURL(backofficeTabId, "", param);
                }
                return rtnurl;

            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return "ERROR";
            }
        }
Пример #13
0
        private string RecalculateSummary(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            var currentcart = new CartData(PortalSettings.Current.PortalId);
                var ajaxInfo = GetAjaxInfo(context, true);
                var shipoption = currentcart.GetShippingOption(); // ship option already set in address update.

                currentcart.AddExtraInfo(ajaxInfo);
                currentcart.SetShippingOption(shipoption);
                currentcart.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartsummary"); // (Legacy) we need to set this so the cart calcs shipping
                currentcart.PurchaseInfo.SetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/shippingprovider", ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/shippingprovider"));

            var shipref = ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/shippingprovider");
            var displayanme = "";
            var shipInfo = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SHIPPING", shipref);
            if (shipInfo != null)
            {
                displayanme = shipInfo.GetXmlProperty("genxml/textbox/shippingdisplayname");
            }
            if (displayanme == "") displayanme = shipref;
            currentcart.PurchaseInfo.SetXmlProperty("genxml/extrainfo/genxml/hidden/shippingdisplayanme", displayanme);

            var shippingproductcode = ajaxInfo.GetXmlProperty("genxml/hidden/shippingproductcode");
                currentcart.PurchaseInfo.SetXmlProperty("genxml/shippingproductcode", shippingproductcode);
                var pickuppointref = ajaxInfo.GetXmlProperty("genxml/hidden/pickuppointref");
                currentcart.PurchaseInfo.SetXmlProperty("genxml/pickuppointref", pickuppointref);
                var pickuppointaddr = ajaxInfo.GetXmlProperty("genxml/hidden/pickuppointaddr");
                currentcart.PurchaseInfo.SetXmlProperty("genxml/pickuppointaddr", pickuppointaddr);

                currentcart.Lang = ajaxInfo.Lang;  // set lang so we can send emails in same language the order was made in.

                currentcart.Save();

                return "OK";
        }
Пример #14
0
 private string RecalculateCart(HttpContext context)
 {
     var strOut = "";
         var ajaxInfoList = GetAjaxInfoList(context);
         var currentcart = new CartData(PortalSettings.Current.PortalId);
         foreach (var ajaxInfo in ajaxInfoList)
         {
                 currentcart.MergeCartInputData(currentcart.GetItemIndex(ajaxInfo.GetXmlProperty("genxml/hidden/itemcode")), ajaxInfo);
         }
         currentcart.Save(StoreSettings.Current.DebugMode);
         strOut = "OK";
         return strOut;
 }
Пример #15
0
        private String GetShippingProviderTemplates(HttpContext context)
        {
            var ajaxInfo = GetAjaxInfo(context);
            var activeprovider = ajaxInfo.GetXmlProperty("genxml/hidden/shippingprovider");
            var currentcart = new CartData(PortalSettings.Current.PortalId);

            var shipoption = currentcart.GetShippingOption(); // we don't want to overwrite the selected shipping option.
            currentcart.AddExtraInfo(ajaxInfo);
            currentcart.SetShippingOption(shipoption);
            currentcart.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartsummary"); // (Legacy) we need to set this so the cart calcs shipping
            currentcart.Save();

            if (activeprovider == "") activeprovider = currentcart.PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/shippingprovider");

            var strRtn = "";
            var pluginData = new PluginData(PortalSettings.Current.PortalId);
            var provList = pluginData.GetShippingProviders();
            if (provList != null && provList.Count > 0)
            {
                if (activeprovider == "") activeprovider = provList.First().Key;
                foreach (var d in provList)
                {
                    var p = d.Value;
                    var shippingkey = p.GetXmlProperty("genxml/textbox/ctrl");
                    var shipprov = ShippingInterface.Instance(shippingkey);
                    if (shipprov != null)
                    {
                        if (activeprovider == d.Key)
                        {
                            var razorTempl = shipprov.GetTemplate(currentcart.PurchaseInfo);
                            var objList = new List<NBrightInfo>();
                            objList.Add(currentcart.PurchaseInfo);
                            if (razorTempl.StartsWith("@"))
                            {
                                strRtn += NBrightBuyUtils.RazorRender(objList, razorTempl, shippingkey + "shippingtemplate", StoreSettings.Current.DebugMode);
                            }
                            else
                            {
                                strRtn += GenXmlFunctions.RenderRepeater(objList[0], razorTempl, "", "XMLData", "", StoreSettings.Current.Settings(), null);
                            }
                        }
                    }
                }
            }
            return strRtn;
        }