Beispiel #1
0
        // dynamically create provider
        private static void CreateProvider()
        {
            string providerName = null;

            _providerList = new Dictionary <string, ShippingInterface>();

            var pluginData = new PluginData(PortalSettings.Current.PortalId);
            var l          = pluginData.GetShippingProviders(false);

            foreach (var p in l)
            {
                var          prov   = p.Value;
                ObjectHandle handle = null;
                handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass"));
                var objProvider = (ShippingInterface)handle.Unwrap();
                var ctrlkey     = prov.GetXmlProperty("genxml/textbox/ctrl");
                var lp          = 1;
                while (_providerList.ContainsKey(ctrlkey))
                {
                    ctrlkey = ctrlkey + lp.ToString("");
                    lp     += 1;
                }
                objProvider.Shippingkey = ctrlkey;
                if (!_providerList.ContainsKey(ctrlkey))
                {
                    _providerList.Add(ctrlkey, objProvider);
                }
                if (prov.GetXmlPropertyBool("genxml/checkbox/default"))
                {
                    _defaultProvider = objProvider;
                }
            }
        }
Beispiel #2
0
        private String GetShippingProviderTemplates()
        {
            var strRtn     = "";
            var pluginData = new PluginData(PortalSettings.Current.PortalId);
            var provList   = pluginData.GetShippingProviders();

            foreach (var d in provList)
            {
                var p           = d.Value;
                var shippingkey = p.GetXmlProperty("genxml/textbox/ctrl");
                var shipprov    = ShippingInterface.Instance(shippingkey);
                if (shipprov != null)
                {
                    var activeprovider = _cartInfo.GetInfo().GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/shippingprovider");
                    // no shipping provider selected, so get the default one.
                    if (activeprovider == "")
                    {
                        activeprovider = provList.First().Key;
                    }
                    if (activeprovider == d.Key)
                    {
                        strRtn += shipprov.GetTemplate(_cartInfo.PurchaseInfo);
                    }
                }
            }
            return(strRtn);
        }
Beispiel #3
0
        // dynamically create provider
        private static void CreateProvider()
        {
            string providerName = null;

            _providerList = new Dictionary<string, ShippingInterface>();

            var pluginData = new PluginData(PortalSettings.Current.PortalId);
            var l = pluginData.GetShippingProviders();

            foreach (var p in l)
            {
                    var prov = p.Value;
                    ObjectHandle handle = null;
                    handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass"));
                    var objProvider = (ShippingInterface) handle.Unwrap();
                    var ctrlkey = prov.GetXmlProperty("genxml/textbox/ctrl");
                    var lp = 1;
                    while (_providerList.ContainsKey(ctrlkey))
                    {
                        ctrlkey = ctrlkey + lp.ToString("");
                        lp += 1;
                    }
                    objProvider.Shippingkey = ctrlkey;
                    _providerList.Add(ctrlkey, objProvider);
            }
        }
Beispiel #4
0
        private static string GetShippingProviderTemplates(HttpContext context)
        {
            var ajaxInfo       = NBrightBuyUtils.GetAjaxInfo(context);
            var activeprovider = ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/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.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)
                {
                    if (activeprovider == d.Key)
                    {
                        var p           = d.Value;
                        var shippingkey = p.GetXmlProperty("genxml/textbox/ctrl");
                        var shipprov    = ShippingInterface.Instance(shippingkey);
                        if (shipprov != null)
                        {
                            var razorTempl = shipprov.GetTemplate(currentcart.PurchaseInfo);
                            if (razorTempl != "")
                            {
                                var objList = new List <NBrightInfo>();
                                objList.Add(currentcart.PurchaseInfo);

                                var nbRazor = new NBrightRazor(objList.Cast <object>().ToList(), NBrightBuyUtils.GetPassSettings(ajaxInfo), HttpContext.Current.Request.QueryString);
                                nbRazor.ModuleId         = -1;
                                nbRazor.FullTemplateName = "";
                                nbRazor.TemplateName     = "";
                                nbRazor.ThemeFolder      = "";
                                nbRazor.Lang             = Utils.GetCurrentCulture();

                                strRtn += NBrightBuyUtils.RazorRender(nbRazor, razorTempl, shippingkey + "shippingtemplate", true);
                            }
                        }
                    }
                }
            }
            return(strRtn);
        }
        public IEncodedString ShippingProviderList(NBrightInfo info, String attributes = "")
        {
            var xpath = "genxml/extrainfo/genxml/radiobuttonlist/shippingprovider";

            var strOut = "";
            var upd    = getUpdateAttr(xpath, attributes);
            var id     = getIdFromXpath(xpath);

            strOut = "<div " + attributes + ">";
            var c     = 0;
            var s     = "";
            var value = info.GetXmlProperty(xpath);

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

            var pluginData = new PluginData(PortalSettings.Current.PortalId);
            var provList   = pluginData.GetShippingProviders();

            foreach (var d in provList)
            {
                var isValid  = true;
                var shipprov = ShippingInterface.Instance(d.Key);
                if (shipprov != null)
                {
                    isValid = shipprov.IsValid(cartData.PurchaseInfo);
                }
                var p = d.Value;
                if (isValid)
                {
                    if (value == "")
                    {
                        value = d.Key;
                    }
                    s = "";
                    if (value == d.Key)
                    {
                        s = "checked";
                    }
                    strOut += "    <input id='" + id + "_" + c.ToString("") + "' " + upd + " name='" + id + "radio' type='radio' value='" + d.Key + "'  " + s + "/><label>" + p.GetXmlProperty("genxml/textbox/name") + "</label>";
                    c      += 1;
                }
            }
            strOut += "</div>";
            return(new RawString(strOut));
        }