Пример #1
0
        public static bool ShouldTake(ProductInfo_V02 prod, bool bEventTicket, bool showAllInventory, bool isHAP)
        {
            bool bValid = bEventTicket
                              ? (prod.TypeOfProduct == ProductType.EventTicket)
                              : (prod.TypeOfProduct != ProductType.EventTicket);

            if (IsChina && bEventTicket && bValid)
            {
                var distributorId = System.Web.HttpContext.Current.User.Identity.Name;
                //if (!string.IsNullOrWhiteSpace(distributorId))
                //    bValid = MyHerbalife3.Ordering.Providers.China.OrderProvider.IsEligibleForEvents(distributorId);
            }

            bValid = isHAP
                ? (prod.TypeOfProduct == ProductType.Product)
                : bValid;

            if (bValid)
            {
                //bValid = prod.SKUs != null && (showAllInventory ? true : !prod.SKUs.Any(s => s.ProductAvailability == ProductAvailabilityType.Unavailable || s.CatalogItem == null ));
                bValid = prod.SKUs != null && prod.SKUs.Any(s => s.IsDisplayable) &&
                         (showAllInventory
                              ? true
                              : prod.SKUs.Any(
                              s =>
                              s.ProductAvailability != ProductAvailabilityType.Unavailable && s.CatalogItem != null));
            }
            return(bValid);
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ProductInfo_V02 currentProduct = Session["CurrentProduct"] as ProductInfo_V02;

            if (!IsPostBack)
            {
                if (currentProduct != null)
                {
                    if (currentProduct.DisplaySizeChart == true)
                    {
                        ProdImage.Attributes.Add("class", string.Format("{0} apparel-image", ProdImage.Attributes["class"]));
                        printThisPageContainer.Visible = false;
                    }

                    divSizeChartLnk.Visible = currentProduct.DisplaySizeChart;
                }
            }

            if (currentProduct != null)
            {
                PrintThisPageContent ucPrintThisPage = LoadControl("~/Ordering/Controls/PrintThisPageContent.ascx") as PrintThisPageContent;
                ucPrintThisPage.BindProduct(currentProduct, SessionInfo.ShowAllInventory, this.AllSKUS);
                printThisPageContainer.Controls.Add(ucPrintThisPage);
            }
        }
        private List <ProductInfo_V02> GetProductInfoV02Mock()
        {
            List <ProductInfo_V02> list  = new List <ProductInfo_V02>();
            ProductInfo_V02        prod2 = new ProductInfo_V02();

            prod2.DisplayName       = "testing";
            prod2.Benefits          = "adadda";
            prod2.CrossSellProducts = null;
            prod2.Details           = "addada";
            prod2.SKUs = new List <SKU_V01> {
                new SKU_V01()
                {
                    CatalogItem      = GetCatalogOtemMock(),
                    Description      = "香草口味 550克",
                    ImagePath        = "/Content/zh-CN/img/Catalog/Products/1316_400X400.jpg",
                    ID               = 46,
                    IsDisplayable    = true,
                    IsPurchasable    = true,
                    MaxOrderQuantity = 2147483647,
                    ParentSKU        = null,
                    PdfName          = "/Content/zh-CN/pdf/Catalog/LPR1316CH_12_OP1_HRes.pdf",
                    Product          = null
                }
            };
            list.Add(prod2);
            return(list);
        }
        /// <summary>
        ///     The should select this cross sell.
        /// </summary>
        /// <param name="cs">
        ///     The cs.
        /// </param>
        /// <param name="shoppingCart">
        ///     The shopping cart.
        /// </param>
        /// <param name="lastSeenProd">
        ///     The last seen prod.
        /// </param>
        /// <param name="lastSeenCrossSell">
        ///     The last seen cross sell.
        /// </param>
        /// <returns>
        ///     The should select this cross sell.
        /// </returns>
        public static bool ShouldSelectThisCrossSell(
            ProductInfo_V02 cs,
            MyHLShoppingCart shoppingCart,
            CrossSellInfo lastSeenProd,
            CrossSellInfo lastSeenCrossSell
            )
        {
            // if it is in shopping cart, do not pick
            if (ifInShoppingCart(shoppingCart, cs))
            {
                return(false);
            }

            if (lastSeenProd != null && cs.ID == lastSeenProd.Product.ID)
            {
                return(false);
            }

            if (lastSeenCrossSell != null && cs.ID == lastSeenCrossSell.Product.ID)
            {
                return(false);
            }

            return(true);
        }
 private bool checkProductAvailability(bool showAllInventory, ProductInfo_V02 product)
 {
     if (product.SKUs == null || product.SKUs.Count == 0)
     {
         return(false);
     }
     // ListView Products
     if (!showAllInventory)
     {
         IEnumerable <SKU_V01> hasStock = from l in product.SKUs
                                          from s in AllSKUS.Keys
                                          where
                                          l.SKU == s &&
                                          AllSKUS[s].ProductAvailability !=
                                          ProductAvailabilityType.Unavailable
                                          select l;
         return(hasStock.Count() != 0);
     }
     else
     {
         IEnumerable <SKU_V01> hasStock = from l in product.SKUs
                                          from s in AllSKUS.Keys
                                          where l.SKU == s
                                          select l;
         return(hasStock.Count() != 0);
     }
 }
Пример #6
0
 protected string getDefaultSKUImagePath(ProductInfo_V02 product)
 {
     if (product.DefaultSKU != null)
     {
         return(product.DefaultSKU.ImagePath);
     }
     return(string.Empty);
 }
        /// <summary>
        ///     The get default sku image path.
        /// </summary>
        /// <param name="prodInfo">
        ///     The prod info.
        /// </param>
        /// <returns>
        ///     The get default sku image path.
        /// </returns>
        private string getDefaultSKUImagePath(ProductInfo_V02 prodInfo)
        {
            if (prodInfo.DefaultSKU != null)
            {
                return(prodInfo.DefaultSKU.ImagePath);
            }

            return(string.Empty);
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ProductInfo_V02 currentProduct = Session["CurrentProduct"] as ProductInfo_V02;

            if (currentProduct != null && currentProduct.DisplaySizeChart == true)
            {
                lbFactSheets.Visible = false;
            }
        }
        /// <summary>
        ///     The get category from product.
        /// </summary>
        /// <param name="product">
        ///     The product.
        /// </param>
        /// <param name="productInfoCatalog">
        ///     The product info catalog.
        /// </param>
        /// <returns>
        /// </returns>
        public static Category_V02 GetCategoryFromProduct(ProductInfo_V02 product,
                                                          ProductInfoCatalog_V01 productInfoCatalog)
        {
            var varProd = from a in productInfoCatalog.AllCategories.Values
                          from p in a.Products
                          where p != null && p.ID == product.ID
                          select a;

            return(varProd.Count() > 0 ? varProd.First() : null);
        }
        /// <summary>
        /// The should take.
        /// </summary>
        /// <param name="prod">
        /// The prod.
        /// </param>
        /// <param name="bEventTicket">
        /// The b event ticket.
        /// </param>
        /// <returns>
        /// The should take.
        /// </returns>
        private bool shouldTake(ProductInfo_V02 prod, bool bEventTicket)
        {
            bool take = bEventTicket
                       ? (prod.TypeOfProduct == ServiceProvider.CatalogSvc.ProductType.EventTicket)
                       : (prod.TypeOfProduct != ServiceProvider.CatalogSvc.ProductType.EventTicket);

            if (take)
            {
                take = prod.SKUs.Any(s => s.IsDisplayable);
            }

            return(take);
        }
        /// <summary>
        ///     The check product availability.
        /// </summary>
        /// <param name="showAllInventory">
        ///     The show all inventory.
        /// </param>
        /// <param name="itemList">
        ///     The item list.
        /// </param>
        private void checkProductAvailability(bool showAllInventory, List <UIProductInfo> itemList)
        {
            // ListView Products
            if (!showAllInventory)
            {
                ProductInfoCatalog_V01 ProductInfoCatalog = ProductsBase.ProductInfoCatalog;
                foreach (ListViewDataItem listItem in Products.Items)
                {
                    var hdProductID = listItem.FindControl("ProductID") as HiddenField;
                    var hdCatID     = listItem.FindControl("CatID") as HiddenField;
                    if (hdProductID != null && hdCatID != null)
                    {
                        string prodID = hdProductID.Value;
                        string catID  = hdCatID.Value;

                        ProductInfo_V02 product = CatalogHelper.getProduct(ProductInfoCatalog, int.Parse(catID),
                                                                           int.Parse(prodID));

                        IEnumerable <SKU_V01> hasStock = from l in product.SKUs
                                                         from s in AllSKUS.Keys
                                                         where
                                                         l.SKU == s &&
                                                         AllSKUS[s].ProductAvailability !=
                                                         ProductAvailabilityType.Unavailable
                                                         select l;
                        //var lbOutofstock = listItem.FindControl("lbOutofstock") as Label;
                        //if (lbOutofstock != null)
                        //{
                        //    lbOutofstock.Visible = hasStock.Count() == 0;
                        //}
                        var td = listItem.FindControl("tdProduct") as HtmlTableCell;
                        if (td != null)
                        {
                            td.Visible = (hasStock != null && hasStock.Count() != 0) || showAllInventory;
                        }
                    }
                }
            }
            //else
            //{
            //    foreach (ListViewDataItem listItem in Products.Items)
            //    {
            //        var lbOutofstock = listItem.FindControl("lbOutofstock") as Label;
            //        if (lbOutofstock != null)
            //        {
            //            lbOutofstock.Visible = false;
            //        }
            //    }
            //}
        }
Пример #12
0
        private static bool ShouldTake(ProductInfo_V02 prod, bool isEventTicket)
        {
            var take = isEventTicket
                           ? (prod.TypeOfProduct == ProductType.EventTicket)
                           : (prod.TypeOfProduct != ProductType.EventTicket);

            if (take)
            {
                if (prod != null && prod.SKUs != null)
                {
                    take = prod.SKUs.Any(s => s.IsDisplayable);
                }
            }

            return(take);
        }
        /// <summary>
        ///     The get default sku price.
        /// </summary>
        /// <param name="prodInfo">
        ///     The prod info.
        /// </param>
        /// <returns>
        ///     The get default sku price.
        /// </returns>
        private string getDefaultSKUPrice(ProductInfo_V02 prodInfo)
        {
            if (HLConfigManager.Configurations.ShoppingCartConfiguration.DisplayRetailPrice)
            {
                if (prodInfo.DefaultSKU != null)
                {
                    SKU_V01 HLSKU;
                    if (AllSKUS.TryGetValue(prodInfo.DefaultSKU.SKU, out HLSKU))
                    {
                        return(getAmountString(HLSKU.CatalogItem != null ? HLSKU.CatalogItem.ListPrice : 0.0M));
                    }
                }
            }

            return(string.Empty);
        }
 protected void populateProducts(ProductInfo_V02 product,
                                 bool showAllInventory,
                                 Dictionary <string, SKU_V01> AllSKUS)
 {
     if (product != null)
     {
         ProductSKU.DataSource = from s in product.SKUs
                                 from a in AllSKUS.Keys
                                 where
                                 s.SKU == a &&
                                 (showAllInventory ||
                                  (showAllInventory == false &&
                                   s.ProductAvailability != ProductAvailabilityType.Unavailable))
                                 select AllSKUS[a];
         ProductSKU.DataBind();
     }
 }
        /// <summary>
        ///     to check if cross sell product is in shopping cart
        /// </summary>
        /// <param name="shoppingCart">
        ///     The shopping Cart.
        /// </param>
        /// <param name="cs">
        ///     The cs.
        /// </param>
        /// <returns>
        ///     The if in shopping cart.
        /// </returns>
        private static bool ifInShoppingCart(MyHLShoppingCart shoppingCart, ProductInfo_V02 cs)
        {
            if (shoppingCart != null && shoppingCart.ShoppingCartItems != null)
            {
                // if already in shopping cart, return true
                var prods =
                    from s in shoppingCart.ShoppingCartItems
                    where s != null && s.ProdInfo != null && s.ProdInfo.ID == cs.ID
                    select s;

                if (prods.Count() > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        ///     The if out of stock.
        /// </summary>
        /// <param name="product">
        ///     The product.
        /// </param>
        /// <param name="allSKUs">
        ///     The all sk us.
        /// </param>
        /// <returns>
        ///     The if out of stock.
        /// </returns>
        public static bool IfOutOfStock(
            ProductInfo_V02 product,
            // cross sell prod id
            Dictionary <string, SKU_V01> allSKUs)
        {
            if (product != null && product.SKUs != null)
            {
                var skuList = from s in product.SKUs
                              from a in allSKUs.Keys
                              where
                              s.SKU == a &&
                              allSKUs[a].ProductAvailability != ProductAvailabilityType.Unavailable
                              select s;
                return(skuList.Count() == 0);
            }

            return(false);
        }
Пример #17
0
        public void Show()
        {
            ProductInfo_V02 currentProduct = Session["CurrentProduct"] as ProductInfo_V02;

            if (currentProduct != null)
            {
                PrintThisPageContent ucPrintThisPage = LoadControl("~/Ordering/Controls/PrintThisPageContent.ascx") as PrintThisPageContent;
                ucPrintThisPage.BindProduct(currentProduct, SessionInfo.ShowAllInventory, this.AllSKUS);
                if (Panel1.Controls.Count > 1)
                {
                    (this.Page.Master as OrderingMaster).EventBus.DeregisterObject(Panel1.Controls[1]);
                    Panel1.Controls.RemoveAt(1);
                }
                Panel1.Controls.Add(ucPrintThisPage);
            }
            pnlPrintThisPage.Style["display"] = "inline";
            upPrintThisPage.Update();
        }
        public void BindProduct(ProductInfo_V02 product, bool showAllInventory, Dictionary <string, SKU_V01> allSKUS)
        {
            lbProductName.Text    = product.DisplayName;
            lbOverview.Text       = product.Overview;
            pDetails.InnerHtml    = product.Details ?? string.Empty;
            lbDetails.Visible     = pDetails.InnerHtml != string.Empty;
            pBenefits.InnerHtml   = product.Benefits ?? string.Empty;
            lbKeyBenefits.Visible = pBenefits.InnerHtml != string.Empty;
            pUsage.InnerHtml      = product.Usage ?? string.Empty;
            lbUsage.Visible       = pUsage.InnerHtml != string.Empty;
            pQuickFacts.InnerHtml = product.FastFacts ?? string.Empty;
            lbFastFacts.Visible   = pQuickFacts.InnerHtml != string.Empty;
            imgProduct.Src        = product.DefaultSKU.ImagePath ?? string.Empty;

            // icons
            if (product.Icons != null)
            {
                addIcons(product.Icons);
                tabIcons.Visible = product.Icons != null && product.Icons.Count > 0;
            }
            else
            {
                tabIcons.Visible = false;
            }

            // Disclaimers
            if (product.Disclaimers != null)
            {
                Disclaimer.DataSource = (from p in product.Disclaimers
                                         select p.Description);
                Disclaimer.DataBind();
                divDisclaimer.Visible = product.Disclaimers.Count > 0;
            }
            else
            {
                divDisclaimer.Visible = false;
            }
            populateProducts(product, showAllInventory, allSKUS);
        }
Пример #19
0
 public CrossSellInfo(int categoryID, ProductInfo_V02 product)
 {
     CategoryID = categoryID;
     Product    = product;
 }
 //Overloaded Method to get the missing property via querystring
 public void BindProduct(ProductInfo_V02 product, bool showAllInventory, Dictionary <string, SKU_V01> allSKUS, string isPC)
 {
     _isPC = isPC;
     BindProduct(product, showAllInventory, allSKUS);
 }
 public ProductDetailFooter(ProductInfo_V02 prodInfo)
 {
     ProdInfo = prodInfo;
 }
        protected override void dataBind(Category_V02 currCategory, ProductInfo_V02 currProduct)
        {
            if (currProduct != null)
            {
                if (currProduct.Links != null && currProduct.Links.Count > 0)
                {
                    ProductLinks.Visible = true;
                    ProductLinks.DataBind(currProduct.Links);
                }
                else
                {
                    ProductLinks.Visible = false;
                }

                // check hot key
                //if (!string.IsNullOrEmpty(currProduct.HotKeys))
                //{
                //    var si = new ScriptInjecter();
                //    si.Text = currProduct.HotKeys;
                //    divAddscript.Controls.Add(si);
                //}

                uxProductName.InnerHtml = currProduct.DisplayName;

                // overview
                if (!string.IsNullOrEmpty(currProduct.Overview))
                {
                    this.uxOverview.InnerHtml = currProduct.Overview;
                    lbOverview.Visible        = true;
                }
                else
                {
                    lbOverview.Visible = false;
                }

                // key benefits
                if (!string.IsNullOrEmpty(currProduct.Benefits))
                {
                    pBenefits.InnerHtml   = currProduct.Benefits;
                    lbKeyBenefits.Visible = true;
                }
                else
                {
                    lbKeyBenefits.Visible = false;
                }

                // usage
                if (!string.IsNullOrEmpty(currProduct.Usage))
                {
                    this.pUsage.InnerHtml = currProduct.Usage;
                    lbUsage.Visible       = true;
                }
                else
                {
                    lbUsage.Visible = false;
                }

                //fast facts
                if (!string.IsNullOrEmpty(currProduct.FastFacts))
                {
                    pQuickFacts.InnerHtml = currProduct.FastFacts;
                    lbFastFacts.Visible   = true;
                }
                else
                {
                    lbFastFacts.Visible = false;
                }


                ProdImage.ImageName = getDefaultSKUImagePath(currProduct);
                //ProdImage.Enlarged = false;

                ProductInfoFooter1.ProdDetails = new ProductDetailFooter(currProduct);
            }
        }
Пример #23
0
 /// <summary>
 /// The get bread crumb.
 /// </summary>
 /// <param name="currentCategory">
 /// The current category.
 /// </param>
 /// <param name="rootCategory">
 /// The root category.
 /// </param>
 /// <returns>
 /// The get bread crumb.
 /// </returns>
 public static string getBreadCrumbText(Category_V02 currentCategory, Category_V02 rootCategory, ProductInfo_V02 product)
 {
     if (currentCategory == null || rootCategory == null)
     {
         return(string.Empty);
     }
     try
     {
         Category_V02        category     = rootCategory;
         List <Category_V02> listCategory = new List <Category_V02>();
         while (category != null)
         {
             category = CatalogHelper.getCategory(currentCategory, category, ref listCategory);
         }
         if (rootCategory.SubCategories == null)
         {
             listCategory.Add(rootCategory);
         }
         return(CatalogHelper.getBreadCrumbText(currentCategory, rootCategory, listCategory) + product.DisplayName);
     }
     catch
     {
         LoggerHelper.Error(string.Format("Error getBreadCrumb catID : {0}", currentCategory.ID));
     }
     return(string.Empty);
 }