示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager scrptMgr = Page.Master.FindControl <ScriptManager>("scrptMgr");

            scrptMgr.Scripts.Add(new ScriptReference("~/jscripts/product.js"));

            if (AppLogic.AppConfigBool("Minicart.UseAjaxAddToCart"))
            {
                scrptMgr.Services.Add(new ServiceReference("~/actionservice.asmx"));
            }


            m_EP = new ShowEntityPage(EntityDefinitions.readonly_GenreEntitySpecs, this);
            m_EP.Page_Load(sender, e);

            PayPalAd entityPageAd = new PayPalAd(PayPalAd.TargetPage.Entity);

            if (entityPageAd.Show)
            {
                ltPayPalAd.Text = entityPageAd.ImageScript;
            }

            litOutput.Text = m_EP.GetOutput();

            // check if the postback was caused by an addtocart button
            if (this.IsPostBack && m_EP.IsAddToCartPostBack)
            {
                HandleAddToCart();
                return;
            }
        }
        public ActionResult Index()
        {
            var customer = HttpContext.GetCustomer();

            var homePageAd = new PayPalAd(PayPalAd.TargetPage.Home);

            var homeViewModel = new HomeViewModel
            {
                PayPalAd  = homePageAd.ImageMarkup,
                PageTitle = string.Format(
                    AppLogic.GetString("default.aspx.1", customer.SkinID, customer.LocaleSetting),
                    AppLogic.AppConfig("StoreName")),
            };

            return(View(homeViewModel));
        }
        private void CreatePreviewBanners()
        {
            PayPalAd homePageAd    = new PayPalAd(PayPalAd.TargetPage.Home);
            PayPalAd cartPageAd    = new PayPalAd(PayPalAd.TargetPage.Cart);
            PayPalAd productPageAd = new PayPalAd(PayPalAd.TargetPage.Product);
            PayPalAd entityPageAd  = new PayPalAd(PayPalAd.TargetPage.Entity);

            ltHomeScript.Text    = !string.IsNullOrEmpty(homePageAd.ImageMarkup) ? string.Format("<div>Your Home Page Banner ({0}):</div>{1}", homePageAd.ImageDimensions, homePageAd.ImageMarkup) : string.Empty;
            ltCartScript.Text    = !string.IsNullOrEmpty(cartPageAd.ImageMarkup) ? string.Format("<div>Your Shopping Cart Page Banner ({0}):</div>{1}", cartPageAd.ImageDimensions, cartPageAd.ImageMarkup) : string.Empty;
            ltProductScript.Text = !string.IsNullOrEmpty(productPageAd.ImageMarkup) ? string.Format("<div>Your Product Page Banner ({0}):</div>{1}", productPageAd.ImageDimensions, productPageAd.ImageMarkup) : string.Empty;
            ltEntityScript.Text  = !string.IsNullOrEmpty(entityPageAd.ImageMarkup) ? string.Format("<div>Your Entity Page Banner ({0}):</div>{1}", entityPageAd.ImageDimensions, entityPageAd.ImageMarkup) : string.Empty;

            pnlHomeScript.Visible    = AppLogic.AppConfigBool("PayPal.Ads.ShowOnHomePage");
            pnlCartScript.Visible    = AppLogic.AppConfigBool("PayPal.Ads.ShowOnCartPage");
            pnlProductScript.Visible = AppLogic.AppConfigBool("PayPal.Ads.ShowOnProductPage");
            pnlEntityScript.Visible  = AppLogic.AppConfigBool("PayPal.Ads.ShowOnEntityPage");
        }
示例#4
0
 public KitAddToCartViewModel(
     string regularBasePrice,
     string basePrice,
     string customizedPrice,
     string customerLevelPrice,
     bool isUnorderable,
     bool isCallToOrder,
     bool showRegularBasePrice,
     bool showBasePrice,
     bool showCustomerLevelPrice,
     bool showWishlistButton,
     bool showBuyButton,
     bool showQuantity,
     bool hidePriceUntilCart,
     SelectList restrictedQuantities,
     PayPalAd payPalAd,
     bool showSchemaOrgPrice,
     string schemaBasePrice,
     string isoThreeLetterCurrency,
     string schemaProductUrl,
     string schemaOfferUrl,
     CartTypeEnum cartType)
 {
     RegularBasePrice       = regularBasePrice;
     BasePrice              = basePrice;
     CustomizedPrice        = customizedPrice;
     CustomerLevelPrice     = customerLevelPrice;
     IsUnorderable          = isUnorderable;
     IsCallToOrder          = isCallToOrder;
     ShowRegularBasePrice   = showRegularBasePrice;
     ShowBasePrice          = showBasePrice;
     ShowCustomerLevelPrice = showCustomerLevelPrice;
     ShowWishlistButton     = showWishlistButton;
     ShowBuyButton          = showBuyButton;
     ShowQuantity           = showQuantity;
     RestrictedQuantities   = restrictedQuantities;
     PayPalAd               = payPalAd;
     HidePriceUntilCart     = hidePriceUntilCart;
     ShowSchemaOrgPrice     = showSchemaOrgPrice;
     SchemaBasePrice        = schemaBasePrice;
     IsoThreeLetterCurrency = isoThreeLetterCurrency;
     SchemaProductUrl       = schemaProductUrl;
     SchemaOfferUrl         = schemaOfferUrl;
     CartType               = cartType;
 }
示例#5
0
 public AddToCartViewModel(
     bool showQuantity,
     SelectList restrictedQuantities,
     bool customerEntersPrice,
     string customerEntersPricePrompt,
     SelectList colorOptions,
     string colorOptionPrompt,
     SelectList sizeOptions,
     string sizeOptionPrompt,
     string textOptionPrompt,
     bool showTextOption,
     bool requiresTextOption,
     int textOptionMaxLength,
     bool isCallToOrder,
     bool showBuyButton,
     bool showWishlistButton,
     PayPalAd payPalAd,
     bool showBuySafeKicker,
     string buySafeKickerType,
     bool colorSelectorChangesImage,
     bool isSimpleProduct,
     CartTypeEnum cartType)
 {
     ShowQuantity              = showQuantity;
     RestrictedQuantities      = restrictedQuantities;
     CustomerEntersPrice       = customerEntersPrice;
     CustomerEntersPricePrompt = customerEntersPricePrompt;
     ColorOptions              = colorOptions;
     ColorOptionPrompt         = colorOptionPrompt;
     SizeOptions               = sizeOptions;
     SizeOptionPrompt          = sizeOptionPrompt;
     TextOptionPrompt          = textOptionPrompt;
     ShowTextOption            = showTextOption;
     RequiresTextOption        = requiresTextOption;
     TextOptionMaxLength       = textOptionMaxLength;
     IsCallToOrder             = isCallToOrder;
     ShowBuyButton             = showBuyButton;
     ShowWishlistButton        = showWishlistButton;
     PayPalAd                  = payPalAd;
     ShowBuySafeKicker         = showBuySafeKicker;
     BuySafeKickerType         = buySafeKickerType;
     ColorSelectorChangesImage = colorSelectorChangesImage;
     IsSimpleProduct           = isSimpleProduct;
     CartType                  = cartType;
 }
示例#6
0
        public ActionResult Index()
        {
            var customer = HttpContext.GetCustomer();

            var homePageAd = new PayPalAd(PayPalAd.TargetPage.Home);

            var homeViewModel = new HomeViewModel
            {
                PayPalAd = homePageAd.Show
                                        ? homePageAd.ImageScript
                                        : string.Empty,
                PageTitle = string.Format(
                    "Welcome to {0}",
                    AppLogic.AppConfig("StoreName")),
            };

            return(View(homeViewModel));
        }
示例#7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_EP = new ShowEntityPage(EntityDefinitions.readonly_CategoryEntitySpecs, this);
            m_EP.Page_Load(sender, e);

            PayPalAd entityPageAd = new PayPalAd(PayPalAd.TargetPage.Entity);

            ((System.Web.UI.WebControls.Label)Master.FindControl("lblPageHeading")).Text = SEDescription;

            string parentCategoryName = string.Empty;
            string parentCategoryID   = string.Empty;

            GetParentCategory(ref parentCategoryName, ref parentCategoryID);

            if (!string.IsNullOrEmpty(parentCategoryName))
            {
                ((System.Web.UI.WebControls.HyperLink)Master.FindControl("lnkCategory")).Text        = parentCategoryName;
                ((System.Web.UI.WebControls.HyperLink)Master.FindControl("lnkCategory")).NavigateUrl = "~/c-" + parentCategoryID + "-" + parentCategoryName.Replace(" ", "-") + ".aspx";

                ((System.Web.UI.WebControls.Label)Master.FindControl("lblSperator")).Text = ">>";

                ((System.Web.UI.WebControls.HyperLink)Master.FindControl("lnkSubCategory")).Text = SEDescription;
                ((System.Web.UI.WebControls.HyperLink)Master.FindControl("lnkSubCategory")).Style.Add("text-decoration", "none");

                ((System.Web.UI.WebControls.Label)Master.FindControl("lblPageHeading")).Visible = false;
            }
            if (entityPageAd.Show)
            {
                ltPayPalAd.Text = entityPageAd.ImageScript;
            }

            litOutput.Text = m_EP.GetOutput();

            CategoryTypeFlag = litOutput.Text.Contains("entity.guidednavigationgrid.xml.config") ? "true" : "false";

            // check if the postback was caused by an addtocart button
            if (IsPostBack && m_EP.IsAddToCartPostBack)
            {
                HandleAddToCart();
                return;
            }
        }
        public ActionResult Detail(int id, string entityType, string searchEngineName, int?productTypeFilterId)
        {
            var normalizedEntityType = AppLogic.ro_SupportedEntities
                                       .Intersect(new[] { entityType }, StringComparer.OrdinalIgnoreCase)
                                       .FirstOrDefault();

            if (normalizedEntityType == null)
            {
                throw new HttpException(404, string.Format("Unsupported entity type: {0}", entityType));
            }

            var entity   = new Entity(id, normalizedEntityType);
            var customer = ControllerContext.HttpContext.GetCustomer();

            //Make sure we've got a valid entity
            if (entity == null ||
                entity.ID == 0 ||
                entity.Published == false ||
                entity.Deleted == true)
            {
                throw new HttpException(404, null);
            }

            //Make sure that this entity is mapped to this store
            var store = new CachelessStore();

            store.StoreID = AppLogic.StoreID();
            var storeMapping = store.GetMapping(entity.EntityType, entity.ID);

            if (AppLogic.GlobalConfigBool("AllowEntityFiltering") == true && !storeMapping.IsMapped)
            {
                throw new HttpException(404, null);
            }

            //301 Redirect to the correct search engine name in the url if it is wrong
            if (!StringComparer.OrdinalIgnoreCase.Equals(searchEngineName, entity.SEName))
            {
                return(RedirectPermanent(Url.BuildEntityLink(normalizedEntityType, id, entity.SEName)));
            }

            //Set last seen values on the profile
            HttpContext.Profile.SetPropertyValue("LastViewedEntityName", entity.EntityType);
            HttpContext.Profile.SetPropertyValue("LastViewedEntityInstanceID", entity.ID.ToString());
            HttpContext.Profile.SetPropertyValue("LastViewedEntityInstanceName", XmlCommon.GetLocaleEntry(entity.Name, customer.LocaleSetting, true));

            //Build up the runtime parameters for the xmlpackage
            var runtimeParameters = string.Format("EntityName={0}&EntityID={1}&ProductTypeFilterID={2}",
                                                  entity.EntityType,
                                                  entity.ID,
                                                  productTypeFilterId ?? 0);

            var entityTypeSpecificRuntimeParamName = "CatID";

            if (entity.EntityType.Equals("manufacturer", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "ManID";
            }
            else if (entity.EntityType.Equals("section", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "SecID";
            }
            else if (entity.EntityType.Equals("distributor", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "DistID";
            }
            else if (entity.EntityType.Equals("genre", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "GenreID";
            }
            else if (entity.EntityType.Equals("vector", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "VectorID";
            }
            else if (entity.EntityType.Equals("section", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "DistID";
            }

            runtimeParameters += string.Format("&{0}={1}", entityTypeSpecificRuntimeParamName, entity.ID);

            //Get a default xmlpackage if we don't have one specified in the database
            var xmlPackageName = string.IsNullOrEmpty(entity.XmlPackage)
                                ? AppLogic.ro_DefaultEntityXmlPackage
                                : entity.XmlPackage;

            //Setup Meta tags
            var metaTitle = XmlCommon.GetLocaleEntry(entity.SETitle, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaTitle))
            {
                metaTitle = string.Format("{0} - {1}", AppLogic.AppConfig("StoreName"), entity.LocaleName);
            }

            var metaDescription = XmlCommon.GetLocaleEntry(entity.SEDescription, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaDescription))
            {
                metaDescription = entity.LocaleName;
            }

            var metaKeywords = XmlCommon.GetLocaleEntry(entity.SEKeywords, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaKeywords))
            {
                metaKeywords = entity.LocaleName;
            }

            //Setup the breadcrumb
            var pageTitle = Breadcrumb.GetEntityBreadcrumb(entity.ID, entity.LocaleName, entity.EntityType, customer);

            //Get the page content from the xmlpackage
            var pageContent = string.Empty;
            var xmlPackage  = new XmlPackage(
                packageName: xmlPackageName,
                customer: customer,
                additionalRuntimeParms: runtimeParameters,
                htmlHelper: ControllerContext.GetHtmlHelper());

            var parser = new Parser();

            pageContent = AppLogic.RunXmlPackage(xmlPackage, parser, customer, customer.SkinID, true, true);
            //override the meta tags from the xmlpackage
            if (xmlPackage.SETitle != string.Empty)
            {
                metaTitle = xmlPackage.SETitle;
            }
            if (xmlPackage.SEDescription != string.Empty)
            {
                metaDescription = xmlPackage.SEDescription;
            }
            if (xmlPackage.SEKeywords != string.Empty)
            {
                metaKeywords = xmlPackage.SEKeywords;
            }
            if (xmlPackage.SectionTitle != string.Empty)
            {
                pageTitle = xmlPackage.SectionTitle;
            }

            var payPalAd = new PayPalAd(PayPalAd.TargetPage.Entity);

            //Build the view model
            var entityViewModel = new EntityViewModel
            {
                Name            = XmlCommon.GetLocaleEntry(entity.Name, customer.LocaleSetting, true),
                MetaTitle       = metaTitle,
                MetaDescription = metaDescription,
                MetaKeywords    = metaKeywords,
                PageTitle       = pageTitle,
                PageContent     = pageContent,
                PayPalAd        = payPalAd.ImageMarkup,
                XmlPackageName  = xmlPackageName
            };

            AppLogic.eventHandler("ViewEntityPage").CallEvent("&ViewEntityPage=true");


            //Override the layout
            var layoutName = string.Empty;

            if (AppLogic.AppConfigBool("TemplateSwitching.Enabled"))
            {
                layoutName = AppLogic.GetCurrentEntityTemplateName(entity.EntityType, entity.ID);
            }

            if (!string.IsNullOrEmpty(layoutName))
            {
                return(View(ActionNames.Detail, layoutName, entityViewModel));
            }
            else
            {
                return(View(entityViewModel));
            }
        }
示例#9
0
        KitAddToCartViewModel BuildDefaultKitAddToCartViewModel(
            KitProductData kitData,
            Product product,
            ProductVariant variant,
            int quantity,
            Customer customer,
            int?cartRecordId)
        {
            var cartType = cartRecordId == null
                                ? CartTypeEnum.ShoppingCart // we won't use this, so what it's set to doesn't matter
                                : CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID())
                           .CartItems
                           .Where(c => c.ShoppingCartRecordID == cartRecordId)
                           .Any()
                                ? CartTypeEnum.ShoppingCart
                                : CartTypeEnum.WishCart;

            var isUnorderable = false;

            if (!AppLogic.AppConfigBool("KitInventory.AllowSaleOfOutOfStock") &&
                (!kitData.HasStock || kitData.HasRequiredOrReadOnlyButUnOrderableKitGroup))
            {
                isUnorderable = true;
            }

            var isCallToOrder = product.IsCalltoOrder;

            kitData.ComputePrices(quantity);

            var kitGroups = new List <KitGroupViewModel>();

            foreach (var group in kitData.Groups)
            {
                var kitItems = new List <KitItemViewModel>();
                foreach (var item in group.Items)
                {
                    var priceDeltaDisplay = FormatCurrencyDisplay(item.PriceDelta, customer, variant.IsTaxable);
                    var showOutOfStock    = item.HasMappedVariant &&
                                            !item.VariantHasStock &&
                                            !AppLogic.AppConfigBool("KitInventory.AllowSaleOfOutOfStock") &&
                                            AppLogic.AppConfigBool("KitInventory.ShowOutOfStockMessage");

                    var kitItemRelativePriceDeltaDisplayText = KitItemRelativePriceDeltaDisplayText(item, customer.CurrencySetting, variant.IsTaxable, kitData);

                    kitItems.Add(new KitItemViewModel
                    {
                        Name        = item.Name,
                        NameDisplay = !string.IsNullOrEmpty(kitItemRelativePriceDeltaDisplayText)
                                                        ? string.Format("{0} [{1}]", item.Name, kitItemRelativePriceDeltaDisplayText)
                                                        : item.Name,
                        Description       = item.Description,
                        IsDefault         = item.IsDefault,
                        PriceDelta        = item.PriceDelta,
                        PriceDeltaDisplay = priceDeltaDisplay,
                        WeightDelta       = item.WeightDelta,
                        DisplayOrder      = item.DisplayOrder,
                        Id         = item.Id,
                        IsSelected = item.IsSelected,
                        TextOption = item.TextOption,
                        ImageUrl   = item.HasImage
                                                        ? item.ImagePath
                                                        : string.Empty,
                        OutOfStockMessage = showOutOfStock
                                                        ? "Out of stock"
                            : string.Empty
                    });
                }

                var selectedItemId = group.FirstSelectedItem != null
                                        ? group.FirstSelectedItem.Id
                                        : 0;

                var groupViewModel = new KitGroupViewModel
                {
                    Id          = group.Id,
                    Name        = group.Name,
                    Description = group.Description,
                    Summary     = group.Summary,
                    ImageUrl    = group.HasImage
                                                        ? group.ImagePath
                                                        : string.Empty,
                    KitGroupType   = group.SelectionControl,
                    Items          = kitItems,
                    SelectedItemId = selectedItemId,
                    IsRequired     = group.IsRequired,
                    IsReadOnly     = group.IsReadOnly
                };

                kitGroups.Add(groupViewModel);
            }

            var regularBasePrice   = kitData.Price;
            var basePrice          = kitData.BasePrice + kitData.ReadOnlyItemsSum;
            var customizedPrice    = kitData.CustomizedPrice;
            var customerLevelPrice = kitData.LevelPrice;

            PayPalAd payPalAd = null;

            // If this is a single variant product, setup the PayPal ad.
            if (AppLogic.GetNextVariant(product.ProductID, variant.VariantID) == variant.VariantID)
            {
                payPalAd = new PayPalAd(PayPalAd.TargetPage.Product);
            }

            // Values need for the Schema.Org tags
            var storeDefaultCultureInfo = CultureInfo.GetCultureInfo(Localization.GetDefaultLocale());
            var formattedSchemaPrice    = string.Format(storeDefaultCultureInfo, "{0:C}", kitData.BasePrice);
            var schemaRegionInfo        = new RegionInfo(storeDefaultCultureInfo.Name);

            // Build the view model
            return(new KitAddToCartViewModel(
                       isUnorderable: isUnorderable,
                       isCallToOrder: isCallToOrder,
                       regularBasePrice: FormatCurrencyDisplay(regularBasePrice, customer, variant.IsTaxable),
                       basePrice: FormatCurrencyDisplay(basePrice, customer, variant.IsTaxable),
                       customizedPrice: FormatCurrencyDisplay(customizedPrice, customer, variant.IsTaxable),
                       customerLevelPrice: FormatCurrencyDisplay(customerLevelPrice, customer, variant.IsTaxable),
                       showRegularBasePrice: kitData.IsDiscounted,
                       showBasePrice: !AppLogic.AppConfigBool("HideKitPrice"),
                       showCustomerLevelPrice: kitData.HasCustomerLevelPricing,
                       showQuantity: AppLogic.AppConfigBool("ShowQuantityOnProductPage") &&
                       !AppLogic.AppConfigBool("HideKitQuantity"),
                       showBuyButton: AppLogic.AppConfigBool("ShowBuyButtons") &&
                       product.ShowBuyButton &&
                       !AppLogic.HideForWholesaleSite(customer.CustomerLevelID),
                       showWishlistButton: AppLogic.AppConfigBool("ShowWishButtons"),
                       hidePriceUntilCart: product.HidePriceUntilCart,
                       restrictedQuantities: RestrictedQuantityProvider.BuildRestrictedQuantityList(variant.RestrictedQuantities),
                       payPalAd: payPalAd,
                       showSchemaOrgPrice: kitData.BasePrice > 0 && !AppLogic.AppConfigBool("HideKitPrice"),
                       schemaBasePrice: formattedSchemaPrice,
                       isoThreeLetterCurrency: schemaRegionInfo.ISOCurrencySymbol,
                       schemaProductUrl: string.Format("{0}://schema.org/Product", Request.Url.Scheme),
                       schemaOfferUrl: string.Format("{0}://schema.org/Offer", Request.Url.Scheme),
                       cartType: cartType)
            {
                ProductId = product.ProductID,
                VariantId = variant.VariantID,
                CartRecordId = cartRecordId,
                Quantity = quantity,
                KitGroups = kitGroups,

                UpsellProducts = null,
                IsWishlist = false,
                ReturnUrl = UrlHelper.MakeSafeReturnUrl(Request.RawUrl),
                TemporaryImageNameStub = Guid.NewGuid().ToString()
            });
        }
示例#10
0
        public ActionResult Index(int categoryid, string searchEngineName)

        {
            var entity   = new Entity(categoryid, "category");
            var customer = ControllerContext.HttpContext.GetCustomer();

            //Make sure we've got a valid entity
            if (entity == null ||
                entity.ID == 0 ||
                entity.Published == false ||
                entity.Deleted == true)
            {
                throw new HttpException(404, null);
            }

            //Make sure that this entity is mapped to this store
            var store = new CachelessStore();

            store.StoreID = AppLogic.StoreID();
            var storeMapping = store.GetMapping(entity.EntityType, entity.ID);

            if (AppLogic.GlobalConfigBool("AllowEntityFiltering") == true && !storeMapping.IsMapped)
            {
                throw new HttpException(404, null);
            }

            //Set last seen values on the profile
            HttpContext.Profile.SetPropertyValue("LastViewedEntityName", entity.EntityType);
            HttpContext.Profile.SetPropertyValue("LastViewedEntityInstanceID", entity.ID.ToString());
            HttpContext.Profile.SetPropertyValue("LastViewedEntityInstanceName", XmlCommon.GetLocaleEntry(entity.Name, customer.LocaleSetting, true));

            //Build up the runtime parameters for the xmlpackage
            var runtimeParameters = string.Format("EntityName={0}&EntityID={1}&ProductTypeFilterID=0",
                                                  entity.EntityType,
                                                  entity.ID);

            var entityTypeSpecificRuntimeParamName = "CatID";

            runtimeParameters += string.Format("&{0}={1}", entityTypeSpecificRuntimeParamName, entity.ID);

            //Get a default xmlpackage if we don't have one specified in the database
            var xmlPackageName = string.IsNullOrEmpty(entity.XmlPackage)
                ? "category.xml.config"
                : entity.XmlPackage;

            //Setup Meta tags
            var metaTitle = XmlCommon.GetLocaleEntry(entity.SETitle, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaTitle))
            {
                metaTitle = Security.HtmlEncode(string.Format("{0} - {1}", AppLogic.AppConfig("StoreName"), entity.LocaleName));
            }

            var metaDescription = XmlCommon.GetLocaleEntry(entity.SEDescription, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaDescription))
            {
                metaDescription = Security.HtmlEncode(entity.LocaleName);
            }

            var metaKeywords = XmlCommon.GetLocaleEntry(entity.SEKeywords, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaKeywords))
            {
                metaKeywords = Security.HtmlEncode(entity.LocaleName);
            }

            //Setup the breadcrumb
            var pageTitle = Breadcrumb.GetEntityBreadcrumb(entity.ID, entity.LocaleName, entity.EntityType, customer);

            //Get the page content from the xmlpackage
            var pageContent = string.Empty;
            var xmlPackage  = new XmlPackage(
                packageName: xmlPackageName,
                customer: customer,
                additionalRuntimeParms: runtimeParameters,
                htmlHelper: ControllerContext.GetHtmlHelper());

            var parser = new Parser();

            pageContent = AppLogic.RunXmlPackage(xmlPackage, parser, customer, customer.SkinID, true, true);
            //override the meta tags from the xmlpackage
            if (xmlPackage.SETitle != string.Empty)
            {
                metaTitle = xmlPackage.SETitle;
            }
            if (xmlPackage.SEDescription != string.Empty)
            {
                metaDescription = xmlPackage.SEDescription;
            }
            if (xmlPackage.SEKeywords != string.Empty)
            {
                metaKeywords = xmlPackage.SEKeywords;
            }
            if (xmlPackage.SectionTitle != string.Empty)
            {
                pageTitle = xmlPackage.SectionTitle;
            }

            var payPalAd = new PayPalAd(PayPalAd.TargetPage.Entity);

            //Build the view model
            var entityViewModel = new EntityViewModel
            {
                Name            = XmlCommon.GetLocaleEntry(entity.Name, customer.LocaleSetting, true),
                MetaTitle       = metaTitle,
                MetaDescription = metaDescription,
                MetaKeywords    = metaKeywords,
                PageTitle       = pageTitle,
                PageContent     = pageContent,
                PayPalAd        = payPalAd.Show ? payPalAd.ImageScript : string.Empty,
                XmlPackageName  = xmlPackageName
            };

            AppLogic.eventHandler("ViewEntityPage").CallEvent("&ViewEntityPage=true");

            //Override the layout
            var layoutName = string.Empty;

            return(View(entityViewModel));
        }
示例#11
0
        public AddToCartViewModel BuildAddToCartViewModel(
            UrlHelper urlHelper,
            ProductVariant variant,
            Product product,
            CartItem cartItem,
            Customer customer,
            bool showWishlistButton,
            bool colorSelectorChangesImage,
            int defaultQuantity  = 1,
            string selectedSize  = "",
            string selectedColor = "")
        {
            // Build our options and prompts
            var customerEntersPricePrompt = XmlCommon.GetLocaleEntry(variant.CustomerEntersPricePrompt, customer.LocaleSetting, true);

            customerEntersPricePrompt = !string.IsNullOrEmpty(customerEntersPricePrompt)
                                        ? customerEntersPricePrompt
                                        : AppLogic.GetString("common.cs.23", customer.LocaleSetting);

            var textOptionPrompt = XmlCommon.GetLocaleEntry(product.TextOptionPrompt, customer.LocaleSetting, true);

            textOptionPrompt = !string.IsNullOrEmpty(textOptionPrompt)
                                        ? textOptionPrompt
                                        : AppLogic.GetString("common.cs.70", customer.LocaleSetting);

            var sizes            = XmlCommon.GetLocaleEntry(variant.Sizes, Localization.GetDefaultLocale(), true);
            var displaySizes     = XmlCommon.GetLocaleEntry(variant.Sizes, customer.LocaleSetting, true);
            var sizeOptionPrompt = XmlCommon.GetLocaleEntry(product.SizeOptionPrompt, customer.LocaleSetting, true);

            sizeOptionPrompt = !string.IsNullOrEmpty(sizeOptionPrompt)
                                ? sizeOptionPrompt
                                : AppLogic.GetString("AppConfig.SizeOptionPrompt", customer.LocaleSetting);

            var colors            = XmlCommon.GetLocaleEntry(variant.Colors, Localization.GetDefaultLocale(), true);
            var displayColors     = XmlCommon.GetLocaleEntry(variant.Colors, customer.LocaleSetting, true);
            var colorOptionPrompt = XmlCommon.GetLocaleEntry(product.ColorOptionPrompt, customer.LocaleSetting, true);

            colorOptionPrompt = !string.IsNullOrEmpty(colorOptionPrompt)
                                ? colorOptionPrompt
                                : AppLogic.GetString("AppConfig.ColorOptionPrompt", customer.LocaleSetting);

            var quantity = defaultQuantity;

            if (cartItem != null && cartItem.Quantity > 0)
            {
                quantity = cartItem.Quantity;
            }
            else if (variant.MinimumQuantity > 0)
            {
                quantity = variant.MinimumQuantity;
            }
            else if (!string.IsNullOrEmpty(AppLogic.AppConfig("DefaultAddToCartQuantity")))
            {
                quantity = AppLogic.AppConfigUSInt("DefaultAddToCartQuantity");
            }

            selectedSize = cartItem != null
                                        ? AppLogic.CleanSizeColorOption(cartItem.ChosenSize)
                                        : AppLogic.CleanSizeColorOption(selectedSize);;

            selectedColor = cartItem != null
                                        ? AppLogic.CleanSizeColorOption(cartItem.ChosenColor)
                                        : AppLogic.CleanSizeColorOption(selectedColor);

            // If this is a single variant product, setup the PayPal ad.
            PayPalAd payPalAd = null;

            if (AppLogic.GetNextVariant(product.ProductID, variant.VariantID) == variant.VariantID)
            {
                payPalAd = new PayPalAd(PayPalAd.TargetPage.Product);
            }

            var variantCount = DB.GetSqlN(
                sql: "SELECT COUNT(*) AS N FROM ProductVariant WHERE Deleted = 0 and published = 1 and ProductID = @productId",
                parameters: new SqlParameter("productId", product.ProductID));

            // Now build the model
            var model = new AddToCartViewModel(
                showQuantity: (!variant.CustomerEntersPrice &&
                               AppLogic.AppConfigBool("ShowQuantityOnProductPage") &&
                               !product.IsAKit) ||
                !AppLogic.AppConfigBool("HideKitQuantity") &&
                product.IsAKit,
                restrictedQuantities: RestrictedQuantityProvider.BuildRestrictedQuantityList(variant.RestrictedQuantities),
                customerEntersPrice: variant.CustomerEntersPrice,
                customerEntersPricePrompt: customerEntersPricePrompt,
                colorOptions: BuildOptionList(colors, displayColors, customer, product.TaxClassID, colorOptionPrompt),
                colorOptionPrompt: colorOptionPrompt,
                sizeOptions: BuildOptionList(sizes, displaySizes, customer, product.TaxClassID, sizeOptionPrompt),
                sizeOptionPrompt: sizeOptionPrompt,
                requiresTextOption: product.RequiresTextOption,
                showTextOption: product.RequiresTextOption ||
                !string.IsNullOrEmpty(XmlCommon.GetLocaleEntry(product.TextOptionPrompt, customer.LocaleSetting, true)),
                textOptionPrompt: textOptionPrompt,
                textOptionMaxLength: product.TextOptionMaxLength == 0
                                        ? 50
                                        : product.TextOptionMaxLength,
                isCallToOrder: product.IsCalltoOrder,
                showBuyButton: AppLogic.AppConfigBool("ShowBuyButtons") &&
                product.ShowBuyButton &&
                !AppLogic.HideForWholesaleSite(customer.CustomerLevelID),
                showWishlistButton: showWishlistButton && AppLogic.AppConfigBool("ShowWishButtons"),
                payPalAd: payPalAd,
                showBuySafeKicker: (!AppLogic.AppConfigBool("BuySafe.DisableAddToCartKicker") &&
                                    AppLogic.GlobalConfigBool("BuySafe.Enabled") &&
                                    AppLogic.GlobalConfig("BuySafe.Hash").Length != 0),
                buySafeKickerType: AppLogic.AppConfig("BuySafe.KickerType"),
                colorSelectorChangesImage: colorSelectorChangesImage,
                isSimpleProduct: !product.IsAKit &&
                variantCount == 1 &&
                string.IsNullOrEmpty(displaySizes) &&
                string.IsNullOrEmpty(displayColors) &&
                !product.RequiresTextOption &&
                !variant.CustomerEntersPrice,
                cartType: cartItem != null
                                        ? cartItem.CartType
                                        : CartTypeEnum.ShoppingCart) // if no current cart item, this won't be used, so it doesn't matter what it's set to
            {
                ProductId    = variant.ProductID,
                VariantId    = variant.VariantID,
                CartRecordId = cartItem != null
                                        ? cartItem.ShoppingCartRecordID
                                        : 0,
                Quantity             = quantity,
                CustomerEnteredPrice = (cartItem != null && variant.CustomerEntersPrice)
                                        ? cartItem.Price
                                        : 0.00M,
                TextOption = cartItem != null
                                        ? cartItem.TextOption
                                        : String.Empty,
                Color          = selectedColor,
                Size           = selectedSize,
                UpsellProducts = null,
                IsWishlist     = false,
                ReturnUrl      = urlHelper.MakeSafeReturnUrl(HttpContext.Current.Request.RawUrl)
            };

            return(model);
        }
示例#12
0
        ActionResult RenderIndexView(CheckoutStageContext checkoutStageContext, PersistedCheckoutContext persistedCheckoutContext, PaymentMethodInfo selectedPaymentMethod, Customer customer, bool termsAndConditionsAccepted, string returnUrl, bool showCheckoutStageErrors)
        {
            var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID());

            // Build a model and render it
            var billingAddressViewModel = customer.PrimaryBillingAddress != null
                                ? AddressViewModelConverter.ConvertToAddressViewModel(customer.PrimaryBillingAddress, customer)
                                : null;

            var shippingAddressViewModel = customer.PrimaryShippingAddress != null
                                ? AddressViewModelConverter.ConvertToAddressViewModel(customer.PrimaryShippingAddress, customer)
                                : null;

            var cartPageAd           = new PayPalAd(PayPalAd.TargetPage.Cart);
            var gatewayIsTwoCheckout = AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWTWOCHECKOUT &&
                                       selectedPaymentMethod != null &&
                                       selectedPaymentMethod.Name == AppLogic.ro_PMCreditCard;

            var shippingEnabled =
                checkoutStageContext.ShippingAddress.Disabled != true ||
                checkoutStageContext.ShippingMethod.Disabled != true;

            var shippingInfoRequired =
                checkoutStageContext.ShippingAddress.Required == true ||
                checkoutStageContext.ShippingMethod.Required == true;

            var displayBillingSection = checkoutStageContext.BillingAddress.Disabled != true;

            // nal
            //var allowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo");
            var allowShipToDifferentThanBillTo = true;

            //  Display the shipping section only if shipping is enabled on the site. If so, than if shipping can be different
            //  than billing, we need to show the form. If shipping and billing can be different or the current payment
            //  option doesn't care about billing, then show just the shipping section and that address will be used for
            //  both shipping and billing.
            var displayShippingSection = shippingEnabled && allowShipToDifferentThanBillTo;

            var checkoutIsOffsiteOnly   = PaymentOptionProvider.CheckoutIsOffsiteOnly(customer, cart);
            var paymentMethodStageState = ConvertStageStatusToDisplayState(checkoutStageContext.PaymentMethod, showCheckoutStageErrors);

            var model = new CheckoutIndexViewModel(
                selectedPaymentMethod: selectedPaymentMethod,
                selectedBillingAddress: billingAddressViewModel,
                selectedShippingAddress: shippingAddressViewModel,
                checkoutButtonDisabled: checkoutStageContext.PlaceOrderButton.Fulfilled != true,
                showOver13Required: Over13Required(customer),
                showOkToEmail: AppLogic.AppConfigBool("Checkout.ShowOkToEmailOnCheckout"),
                showTermsAndConditions: AppLogic.AppConfigBool("RequireTermsAndConditionsAtCheckout"),
                displayGiftCardSetup: checkoutStageContext.GiftCardSetup.Required == true,
                showOrderOptions: cart.AllOrderOptions.Any(),
                // nal
                //showOrderNotes: !AppLogic.AppConfigBool("DisallowOrderNotes"),
                showOrderNotes: true,
                showRealTimeShippingInfo: AppLogic.AppConfigBool("RTShipping.DumpDebugXmlOnCheckout") && (customer.IsAdminUser || customer.IsAdminSuperUser),
                allowShipToDifferentThanBillTo: allowShipToDifferentThanBillTo,
                displayShippingSection: displayShippingSection,
                displayBillingSection: displayBillingSection,
                shippingInfoIsRequired: shippingInfoRequired,
                displayTwoCheckoutText: gatewayIsTwoCheckout,
                displayContinueOffsite: selectedPaymentMethod != null && selectedPaymentMethod.Location == PaymentMethodLocation.Offsite,
                // nal
                //showPromotions: AppLogic.AppConfigBool("Promotions.Enabled"),
                showPromotions: true,
                // nal
                //showGiftCards: AppLogic.AppConfigBool("GiftCards.Enabled"),
                showGiftCards: true,
                giftCardCoversTotal: cart.GiftCardCoversTotal(),
                checkoutIsOffsiteOnly: checkoutIsOffsiteOnly,
                pageTitle: "Secure Checkout",
                payPalBanner: cartPageAd.Show ? cartPageAd.ImageScript : null,
                accountStageState: ConvertStageStatusToDisplayState(checkoutStageContext.Account, showCheckoutStageErrors),
                // nal
                continueShoppingUrl: Url.Content(returnUrl),
                offsiteCheckoutError: checkoutIsOffsiteOnly && paymentMethodStageState == CheckoutStageDisplayState.Failing
                                        ? "Please choose a payment method"
                    : string.Empty,
                paymentMethodStageState: paymentMethodStageState,
                billingAddressStageState: ConvertStageStatusToDisplayState(checkoutStageContext.BillingAddress, showCheckoutStageErrors),
                shippingAddressStageState: ConvertStageStatusToDisplayState(checkoutStageContext.ShippingAddress, showCheckoutStageErrors),
                shippingMethodStageState: ConvertStageStatusToDisplayState(checkoutStageContext.ShippingMethod, showCheckoutStageErrors),
                giftCardSetupStageState: ConvertStageStatusToDisplayState(checkoutStageContext.GiftCardSetup, showCheckoutStageErrors))
            {
                Over13Selected             = persistedCheckoutContext.Over13Checked,
                OkToEmailSelected          = customer.OKToEMail,
                TermsAndConditionsAccepted = termsAndConditionsAccepted
            };

            return(View(model));
        }