Example #1
0
        public string DoRenderBeforeBodyEnd()
        {
            string res;

            var listid = ModuleSettingsProvider.GetSettingValue <string>("PriceListID", ModuleID);

            string url = HttpContext.Current.Request.Url.ToString().ToLower();

            if (url.Contains("default.aspx"))
            {
                res = string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView', productid: '', pagetype: 'home',totalvalue: '', list: '{0}' }});</script>", listid);
            }
            else if (url.Contains("catalog.aspx"))
            {
                res =
                    string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView', productid: '', pagetype: 'category', totalvalue:'', list: '{0}' }});</script>", listid);
            }
            else if (url.Contains("details.aspx"))
            {
                Offer mainOffer;
                var   product = ProductService.GetProduct(HttpContext.Current.Request["ProductID"].TryParseInt());
                if (product != null &&
                    (mainOffer = OfferService.GetMainOffer(product.Offers, product.AllowPreOrder,
                                                           HttpContext.Current.Request["color"].TryParseInt(true), HttpContext.Current.Request["size"].TryParseInt(true))) != null)
                {
                    res =
                        string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView',productid: '{0}',pagetype: 'product', totalvalue:'{1}',list: '{2}' }});</script>", mainOffer.OfferId, mainOffer.Price.ToString("F2").Replace(",", "."), listid);
                }
                else
                {
                    res = string.Empty;
                }
            }
            else if (url.Contains("shoppingcart.aspx"))
            {
                var cart = ShoppingCartService.CurrentShoppingCart;

                res = string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView',productid: [{0}], pagetype: 'cart', totalvalue:'{1}', list: '{2}' }});</script>", cart.Select(o => "'" + o.OfferId + "'").AggregateString(","), cart.TotalPrice.ToString("F2").Replace(",", "."), listid);
            }
            else
            {
                res = string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView', productid: '', pagetype: 'other', totalvalue: '', list: '{0}' }});</script>", listid);
            }

            return(res);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Product.ProductPhotos.Any())
            {
                Offer currentOffer = OfferService.GetMainOffer(Product.Offers, Product.AllowPreOrder, Request["color"].TryParseInt(true), Request["size"].TryParseInt(true));

                if (currentOffer != null)
                {
                    MainPhoto = currentOffer.Photo;
                }
                else
                {
                    MainPhoto =
                        Product.ProductPhotos.OrderByDescending(item => item.Main)
                        .ThenBy(item => item.PhotoSortOrder)
                        .FirstOrDefault(item => item.Main) ?? new Photo(0, Product.ProductId, PhotoType.Product);
                }

                if (MainPhoto == null)
                {
                    //nophoto object
                    MainPhoto = new Photo(0, Product.ProductId, PhotoType.Product)
                    {
                        PhotoName = ""
                    };
                }

                lvPhotos.DataSource = Product.ProductPhotos;
                lvPhotos.DataBind();

                carouselDetails.Visible      = lvPhotos.Items.Count > 1;
                pnlPhoto.Visible             = true;
                pnlPhoto.Attributes["style"] = "width:" + SettingsPictureSize.MiddleProductImageWidth + "px";
                pnlNoPhoto.Visible           = false;
            }
            else
            {
                pnlPhoto.Visible = false;
                pnlNoPhoto.Attributes["style"] = "width:" + SettingsPictureSize.MiddleProductImageWidth + "px";
                pnlNoPhoto.Visible             = true;
            }


            LoadModules();
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ProductId == 0)
            {
                Error404();
                return;
            }

            //if not have category
            if (ProductService.GetCountOfCategoriesByProductId(ProductId) == 0)
            {
                Error404();
                return;
            }

            // --- Check product exist ------------------------
            CurrentProduct = ProductService.GetProduct(ProductId);

            if (CurrentProduct == null || CurrentProduct.Enabled == false || CurrentProduct.CategoryEnabled == false)
            {
                Error404();
                return;
            }

            btnAdd.Text            = SettingsCatalog.BuyButtonText;
            btnOrderByRequest.Text = SettingsCatalog.PreOrderButtonText;

            if (CurrentProduct.TotalAmount <= 0 || CurrentProduct.MainPrice == 0)
            {
                divAmount.Visible = false;
            }


            //CompareControl.ProductId = ProductId;

            CurrentOffer = OfferService.GetMainOffer(CurrentProduct.Offers, CurrentProduct.AllowPreOrder, Request["color"].TryParseInt(true), Request["size"].TryParseInt(true));

            if (CurrentOffer != null)
            {
                BuyInOneClick.OfferID = CurrentOffer.OfferId;

                sizeColorPicker.SelectedOfferId = CurrentOffer.OfferId;

                //CompareControl.Visible = divCompare.Visible = SettingsCatalog.EnableCompareProducts;
                //CompareControl.OfferId = CurrentOffer.OfferId;
                //CompareControl.IsSelected =
                //    ShoppingCartService.CurrentCompare.Any(p => p.Offer.OfferId == CurrentOffer.OfferId);

                //WishlistControl.OfferId = CurrentOffer.OfferId;
                //divWishlist.Visible = SettingsDesign.WishListVisibility;
            }
            else
            {
                //CompareControl.Visible = divCompare.Visible = false;
                //divWishlist.Visible = false;
                pnlPrice.Visible = false;
            }

            BuyInOneClick.ProductId       = CurrentProduct.ProductId;
            BuyInOneClick.SelectedOptions = productCustomOptions.SelectedOptions;
            BuyInOneClick.CustomOptions   = productCustomOptions.CustomOptions;

            sizeColorPicker.ProductId = ProductId;

            divUnit.Visible = (CustomerContext.CurrentCustomer.IsAdmin || AdvantShop.Trial.TrialService.IsTrialEnabled) && SettingsMain.EnableInplace ? true : CurrentProduct.Unit.IsNotEmpty();

            rating.ProductId  = CurrentProduct.ID;
            rating.Rating     = CurrentProduct.Ratio;
            rating.ShowRating = SettingsCatalog.EnableProductRating;
            rating.ReadOnly   = RatingService.DoesUserVote(ProductId, CustomerContext.CustomerId);

            pnlSize.Visible   = !string.IsNullOrEmpty(CurrentProduct.Size) && (CurrentProduct.Size != "0|0|0") && SettingsCatalog.DisplayDimensions;
            pnlWeight.Visible = CurrentProduct.Weight != 0 && SettingsCatalog.DisplayWeight;

            CurrentBrand     = CurrentProduct.Brand;
            pnlBrand.Visible = CurrentBrand != null && CurrentBrand.Enabled;
            //pnlBrnadLogo.Visible = CurrentBrand != null && CurrentBrand.Enabled && CurrentBrand.BrandLogo != null;

            productPropertiesView.ProductId      = ProductId;
            productBriefPropertiesView.ProductId = ProductId;

            productPhotoView.Product = CurrentProduct;

            ProductVideoView.ProductID = ProductId;
            relatedProducts.ProductIds.Add(ProductId);
            alternativeProducts.ProductIds.Add(ProductId);
            breadCrumbs.Items =
                CategoryService.GetParentCategories(CurrentProduct.CategoryId).Reverse().Select(cat => new BreadCrumbs
            {
                Name = cat.Name,
                Url  = UrlService.GetLink(ParamType.Category, cat.UrlPath, cat.ID)
            }).ToList();
            breadCrumbs.Items.Insert(0, new BreadCrumbs
            {
                Name = Resource.Client_MasterPage_MainPage,
                Url  = UrlService.GetAbsoluteLink("/")
            });

            breadCrumbs.Items.Add(new BreadCrumbs {
                Name = CurrentProduct.Name, Url = null
            });

            RecentlyViewService.SetRecentlyView(CustomerContext.CustomerId, ProductId);

            productReviews.EntityType = EntityType.Product;
            productReviews.EntityId   = ProductId;

            int reviewsCount = SettingsCatalog.ModerateReviews
                                   ? ReviewService.GetCheckedReviewsCount(ProductId, EntityType.Product)
                                   : ReviewService.GetReviewsCount(ProductId, EntityType.Product);

            if (reviewsCount > 0)
            {
                lReviewsCount.Text = string.Format("({0})", reviewsCount);
            }

            //Добавим новые meta
            MetaInfo newMetaInfo = new MetaInfo();

            newMetaInfo                 = CurrentProduct.Meta;
            newMetaInfo.Title           = CurrentProduct.Name + " купить в интернет-магазине Корпорация Игрушек";
            newMetaInfo.MetaDescription = "Интернет-магазин Корпорация Игрушек представляет: " + CurrentProduct.Name + " и еще более 5,5 тысяч видов товаров по оптовым ценам. Порадуйте своего ребенка!";
            newMetaInfo.MetaKeywords    = CurrentProduct.Name;

            metaInfo = SetMeta(newMetaInfo, CurrentProduct.Name);

            //metaInfo = SetMeta(CurrentProduct.Meta, CurrentProduct.Name,
            //    CategoryService.GetCategory(CurrentProduct.CategoryId).Name,
            //    CurrentProduct.Brand != null ? CurrentProduct.Brand.Name : string.Empty,
            //    CatalogService.GetStringPrice(CurrentProduct.MainPrice -
            //                                  CurrentProduct.MainPrice * CurrentProduct.Discount / 100));

            if (SettingsSEO.ProductAdditionalDescription.IsNotEmpty())
            {
                liAdditionalDescription.Text =
                    GlobalStringVariableService.TranslateExpression(
                        SettingsSEO.ProductAdditionalDescription, MetaType.Product, CurrentProduct.Name,
                        CategoryService.GetCategory(CurrentProduct.CategoryId).Name,
                        CurrentProduct.Brand != null ? CurrentProduct.Brand.Name : string.Empty,
                        CatalogService.GetStringPrice(CurrentProduct.MainPrice -
                                                      CurrentProduct.MainPrice * CurrentProduct.Discount / 100));
            }

            LoadModules();

            if (GoogleTagManager.Enabled)
            {
                var tagManager = ((AdvantShopMasterPage)Master).TagManager;
                tagManager.PageType       = GoogleTagManager.ePageType.product;
                tagManager.ProdId         = CurrentOffer != null ? CurrentOffer.ArtNo : CurrentProduct.ArtNo;
                tagManager.ProdName       = CurrentProduct.Name;
                tagManager.ProdValue      = CurrentOffer != null ? CurrentOffer.Price : 0;
                tagManager.CatCurrentId   = CurrentProduct.MainCategory.ID;
                tagManager.CatCurrentName = CurrentProduct.MainCategory.Name;
            }
        }