示例#1
0
    protected string RenderPictureTag(string urlPhoto, string productName, string urlPath)
    {
        string strFormat = string.Empty;

        switch (ViewMode)
        {
        case ProductViewMode.Tiles:
            strFormat = string.Format("<a href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" /></a>", urlPath,
                                      FoldersHelper.GetImageProductPath(ProductImageType.Small, urlPhoto, false), productName);
            break;

        case ProductViewMode.List:
            strFormat = string.Format("<a href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" /></a>", urlPath,
                                      FoldersHelper.GetImageProductPath(ProductImageType.Small, urlPhoto, false), productName);
            break;

        case ProductViewMode.Table:
            if (urlPhoto.IsNotEmpty())
            {
                strFormat = string.Format("abbr=\"{0}\"",
                                          FoldersHelper.GetImageProductPath(ProductImageType.Small, urlPhoto, false));
            }
            break;
        }
        return(strFormat);
    }
示例#2
0
    protected void rptReviews_ItemDataBind(object sender, RepeaterItemEventArgs e)
    {
        if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
        {
            try
            {
                var commentId    = Convert.ToInt32(((DataRowView)e.Item.DataItem)["ReviewId"]);
                var reviewEntity = ReviewService.GetReviewEntity(commentId);
                var url          = ReviewService.GetEntityUrl(reviewEntity.ReviewEntityId, reviewEntity.Type);

                var ibPhoto          = ((HyperLink)e.Item.FindControl("ibPhoto"));
                var requestHyperLink = ((HyperLink)e.Item.FindControl("requestHyperLink"));

                if (!string.IsNullOrEmpty(reviewEntity.Photo))
                {
                    ibPhoto.ImageUrl    = FoldersHelper.GetImageProductPath(ProductImageType.Small, reviewEntity.Photo, false);
                    ibPhoto.Text        = reviewEntity.PhotoDescription;
                    ibPhoto.NavigateUrl = url;
                    ibPhoto.Attributes.Add("abbr", FoldersHelper.GetImageProductPath(ProductImageType.Middle, reviewEntity.Photo, false));
                }
                else
                {
                    ibPhoto.Visible = false;
                }

                requestHyperLink.NavigateUrl = url;
                requestHyperLink.Text        = reviewEntity.Name;
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
                MsgErr("Unable to load product photo");
            }
        }
    }
    private PropertyLinkPhoto UpdateValue(PropertyLinkPhoto valueToHtml)
    {
        Product temp;
        string  outputValue = valueToHtml.PropertyName;

        if (outputValue.Contains("(") && outputValue.Contains(")"))
        {
            outputValue = outputValue.Remove(0, outputValue.IndexOf("(") + 1);
            outputValue = outputValue.Remove(outputValue.IndexOf(")"));
            outputValue = outputValue.Replace(" ", "");
            //ArtNo Bosch
            if (outputValue.Length == 10)
            {
                temp = ProductService.GetProduct(outputValue);
                if (temp != null && temp.UrlPath != string.Empty)
                {
                    outputValue = @"<a href=" + UrlService.GetLink(ParamType.Product, temp.UrlPath, temp.ID) + " class=''link-pv-name'' target='_blank'>" + temp.Name + " [" + temp.ArtNo + "] </a>";
                    valueToHtml.PropertyLink = outputValue;
                    //valueToHtml.PhotoLink = temp.Photo;
                    valueToHtml.PhotoLink = FoldersHelper.GetImageProductPath(ProductImageType.Small, temp.Photo, false);
                }
            }
        }
        return(valueToHtml);
    }
示例#4
0
 protected string RenderPictureTag(string urlPhoto, string productName, string urlPath)
 {
     return(string.Format("<a href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" /></a>", urlPath,
                          urlPhoto.IsNotEmpty()
                                   ? FoldersHelper.GetImageProductPath(ProductImageType.Small, urlPhoto, false)
                                   : "images/nophoto_small.jpg", productName));
 }
示例#5
0
        protected string RenderPictureTag(string urlPhoto, string additionalUrlPhoto, string urlPath, string photoDesc, string productName, int photoId, int productId)
        {
            string strFormat = string.Empty;

            string alt = photoDesc.IsNotEmpty() ? photoDesc : productName + " - " + Resource.ClientPage_AltText + " " + photoId;

            switch (ViewMode)
            {
            case SettingsCatalog.ProductViewMode.Tiles:
                strFormat = string.Format("<a class=\"pv-lnk-photo\" href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" class=\"scp-img p-photo {4}\" {3} /></a>", urlPath,
                                          FoldersHelper.GetImageProductPath(ProductImageType.Small, additionalUrlPhoto.IsNotEmpty() ? additionalUrlPhoto : urlPhoto, false),
                                          HttpUtility.HtmlEncode(alt),
                                          InplaceEditor.Image.AttributesProduct(photoId == 0 ? productId : photoId, productId, ProductImageType.Small, true, !urlPhoto.IsNullOrEmpty(), !urlPhoto.IsNullOrEmpty()),
                                          InplaceEditor.CanUseInplace(RoleActionKey.DisplayCatalog) ? "js-inplace-image-visible-permanent" : "");
                break;

            case SettingsCatalog.ProductViewMode.List:
                strFormat = string.Format("<a class=\"pv-lnk-photo\" href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" class=\"scp-img p-photo {4}\" {3}/></a>", urlPath,
                                          FoldersHelper.GetImageProductPath(ProductImageType.Small, additionalUrlPhoto.IsNotEmpty() ? additionalUrlPhoto : urlPhoto, false),
                                          HttpUtility.HtmlEncode(alt),
                                          InplaceEditor.Image.AttributesProduct(photoId == 0 ? productId : photoId, productId, ProductImageType.Small, true, !urlPhoto.IsNullOrEmpty(), !urlPhoto.IsNullOrEmpty()),
                                          InplaceEditor.CanUseInplace(RoleActionKey.DisplayCatalog) ? "js-inplace-image-visible-permanent" : "");
                break;

            case SettingsCatalog.ProductViewMode.Table:
                if (urlPhoto.IsNotEmpty())
                {
                    strFormat = string.Format("abbr=\"{0}\"",
                                              FoldersHelper.GetImageProductPath(ProductImageType.Small, additionalUrlPhoto.IsNotEmpty() ? additionalUrlPhoto : urlPhoto, false));
                }
                break;
            }
            return(strFormat);
        }
示例#6
0
    protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            try
            {
                var commentId    = Convert.ToInt32(((HiddenField)e.Row.FindControl("hfID")).Value);
                var reviewEntity = ReviewService.GetReviewEntity(commentId);
                var entity       = ReviewService.GetReviewEntity(commentId);
                var url          = ReviewService.GetEntityUrl(reviewEntity.ReviewEntityId, reviewEntity.Type);

                var ibPhoto = ((HyperLink)e.Row.FindControl("ibPhoto"));
                if (!string.IsNullOrEmpty(entity.Photo))
                {
                    ibPhoto.ImageUrl    = FoldersHelper.GetImageProductPath(ProductImageType.XSmall, reviewEntity.Photo, false);
                    ibPhoto.Text        = entity.PhotoDescription;
                    ibPhoto.ToolTip     = entity.PhotoDescription;
                    ibPhoto.NavigateUrl = url;
                    ibPhoto.Attributes.Add("abbr", entity.Photo);
                }
                else
                {
                    ibPhoto.Visible = false;
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
                MsgErr("Unable to load product photo");
            }
        }
    }
示例#7
0
 protected string RenderPictureTag(string urlPhoto, string productName)
 {
     if (string.IsNullOrEmpty(urlPhoto))
     {
         return("<img src=\"images/nophoto_small.jpg\" alt=\"\" />");
     }
     return(string.Format("<img src=\"{0}\" alt=\"{1}\" />", FoldersHelper.GetImageProductPath(ProductImageType.Small, urlPhoto, false), productName));
 }
示例#8
0
 protected string RenderPictureTag(int productId, string strPhoto, string urlpath, string photoDesc)
 {
     return(string.Format("<a href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" title=\"{2}\" class=\"pv-photo\" /></a>",
                          UrlService.GetLink(ParamType.Product, urlpath, productId), strPhoto.IsNotEmpty()
             ? FoldersHelper.GetImageProductPath(ProductImageType.Small, strPhoto, false)
             : "images/nophoto_small.jpg",
                          HttpUtility.HtmlEncode(photoDesc)));
 }
    protected string RenderPictureTag(string urlPhoto, string urlPath, string photoDesc)
    {
        string strFormat = string.Empty;

        strFormat = string.Format("<a href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" title=\"{2}\" /></a>", urlPath,
                                  FoldersHelper.GetImageProductPath(ProductImageType.Small, urlPhoto, false), HttpUtility.HtmlEncode(photoDesc));

        return(strFormat);
    }
示例#10
0
        protected string GetImageItem(string photoName)
        {
            if (File.Exists(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photoName)))
            {
                var abbr = FoldersHelper.GetImageProductPath(ProductImageType.Small, photoName, true);
                return(string.Format("<img abbr='{0}' class='imgtooltip' src='{1}'>", abbr, "images/adv_photo_ico.gif"));
            }

            return("");
        }
示例#11
0
 protected string RenderPictureTag(int productId, string strPhoto, string urlpath)
 {
     return
         (string.Format(
              "<a href=\"{0}\" class=\"compare-link-picture\"><img src=\"{1}\" class=\"compare-picture\"></a>",
              UrlService.GetLink(ParamType.Product, urlpath, productId), strPhoto.IsNotEmpty()
                                                                            ? FoldersHelper.GetImageProductPath(
                  ProductImageType.Small, strPhoto,
                  false)
                                                                            : "images/nophoto_small.jpg"));
 }
示例#12
0
    protected string RenderPicture(int productId)
    {
        var p = ProductService.GetProduct(productId);

        if (p == null || string.IsNullOrEmpty(p.Photo))
        {
            return(string.Format("<img src='{0}' alt=\"\"/>", AdvantShop.Core.UrlRewriter.UrlService.GetAbsoluteLink("images/nophoto_small.jpg")));
        }

        return(String.Format("<img src='{0}'/>", FoldersHelper.GetImageProductPath(ProductImageType.Small, p.Photo, true)));
    }
示例#13
0
 protected string HtmlProductImage()
 {
     return(string.IsNullOrEmpty(_productPhoto)
                ? "<img style=\'margin-right: 30px; border: solid 1px gray;\' src=\'images/nophoto.gif\' />"
                : (_productPhoto.Contains("://")
                       ? "<a rel=\"lightbox\" href=\"" + _productPhoto +
                   "\"><img style=\'margin-right: 30px; border: solid 1px gray;\' width=\'120\' src=\'" +
                   _productPhoto + "\' /></a>"
                       : "<a rel=\"lightbox\" href=\"" +
                   FoldersHelper.GetImageProductPath(ProductImageType.Big, _productPhoto, true) +
                   "\"><img style=\'margin-right: 30px; border: solid 1px gray;\' src=\'" +
                   FoldersHelper.GetImageProductPath(ProductImageType.Small, _productPhoto, true) + "\' /></a>"));
 }
示例#14
0
    protected string RenderOrderListItem(ShoppingCartItem item, int index)
    {
        var result = new StringBuilder();

        if (item.ItemType == EnumItemType.Product)
        {
            var productUrl = UrlService.GetLink(ParamType.Product, item.Product.UrlPath, item.EntityId);

            //td photo
            result.AppendFormat("<td class=\"fullcart-photo-data\"><a href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" /></a></td>",
                                productUrl,
                                item.Product.Photo.IsNotEmpty()
                       ? FoldersHelper.GetImageProductPath(ProductImageType.Small, item.Product.Photo, false)
                       : "images/nophoto_xsmall.jpg",
                                item.Product.Name);

            //td name
            result.AppendFormat("<td class=\"fullcart-name-data\"><div><a href=\"{0}\" class=\"link-pv-name\">{1}</a></div><div class=\"sku\">{2}</div>{3}</td>",
                                productUrl,
                                item.Product.Name,
                                item.Product.ArtNo,
                                RenderSelectedOptions(item.AttributesXml));
        }
        else if (item.ItemType == EnumItemType.Certificate)
        {
            //td photo
            result.AppendFormat("<td class=\"fullcart-photo-data\"><a href=\"#\" onclick=\"return false;\"><img src=\"{0}\" alt=\"{1}\" /></a></td>",
                                "images/giftcertificate/certifacate_xsmall.jpg",
                                Resource.Client_GiftCertificate);

            //td name
            result.AppendFormat("<td class=\"fullcart-name-data\"><div><a href=\"#\" onclick=\"return false;\" class=\"link-pv-name\">{0}</a></div></td>",
                                Resource.Client_GiftCertificate);
        }

        //td price
        result.AppendFormat("<td class=\"fullcart-price-data\"><span class=\"price\">{0}</span></td>",
                            CatalogService.GetStringPrice(item.Price, CurrencyService.CurrentCurrency.Value,
                                                          CurrencyService.CurrentCurrency.Iso3));

        //td amount
        result.AppendFormat("<td class=\"fullcart-count-data\">{0}</td>",
                            item.Amount);

        //td cost price
        result.AppendFormat("<td class=\"fullcart-cost-data\"><span class=\"price\">{0}</span></td>",
                            CatalogService.GetStringPrice(item.Price, 0, item.Amount));

        return(result.ToString());
    }
示例#15
0
        protected static string GetImageProductPath(string photoPath)
        {
            if (photoPath.ToLower().Contains("http://"))
            {
                return(photoPath);
            }

            //const ProductImageType type = ProductImageType.Middle;
            //var appPath = SettingsMain.SiteUrl;

            //Changed By Evgeni gor full photo name in YandexMarket and others
            return(SettingsMain.SiteUrl + "/" + FoldersHelper.GetImageProductPath(ProductImageType.Middle, photoPath, false));
            //appPath + "/" + ImageFolders.ProductImagePath +ImageFolders.ProductPhotoPrefix[type] +photoPath + ImageFolders.ProductPhotoPostfix[type];
        }
示例#16
0
        protected string RenderPictureTag(int productId, string strPhoto, string urlpath, string photoDesc, string productName, int photoId)
        {
            string alt = photoDesc.IsNotEmpty() ? photoDesc : productName + " - " + Resource.ClientPage_AltText + " " + photoId;

            return
                (string.Format(
                     "<a href=\"{0}\" class=\"mp-pv-lnk\"><img src=\"{1}\" alt=\"{2}\" class=\"pv-photo p-photo scp-img {5}\" {3} {4}></a>",
                     UrlService.GetLink(ParamType.Product, urlpath, productId), strPhoto.IsNotEmpty()
                                                                                   ? FoldersHelper.GetImageProductPath(ProductImageType.Small, strPhoto, false)
                                                                                   : "images/nophoto_small.jpg",
                     HttpUtility.HtmlEncode(alt), Mode == SettingsDesign.eMainPageMode.Default ? "style=\"max-width:100%;\"" : "",
                     InplaceEditor.Image.AttributesProduct(photoId == 0 ? productId : photoId, productId, ProductImageType.Small, true, !strPhoto.IsNullOrEmpty(), !strPhoto.IsNullOrEmpty()),
                     InplaceEditor.CanUseInplace(RoleActionKey.DisplayCatalog) ? "js-inplace-image-visible-permanent" : ""));
        }
示例#17
0
        protected string GetImageProductPath(string photoPath)
        {
            if (string.IsNullOrEmpty(photoPath))
            {
                photoPath = "";
            }

            photoPath = photoPath.Trim();

            if (photoPath.ToLower().Contains("http://"))
            {
                return(photoPath);
            }
            return(ShopUrl.TrimEnd('/') + "/" + FoldersHelper.GetImageProductPath(ProductImageType.Big, photoPath, false));
        }
示例#18
0
        protected string RenderPicture(int productId, int?photoId)
        {
            if (photoId != null)
            {
                var photo = PhotoService.GetPhoto((int)photoId);
                if (photo != null)
                {
                    return(string.Format("<img src='{0}'/>", FoldersHelper.GetImageProductPath(ProductImageType.XSmall, photo.PhotoName, true)));
                }
            }

            var p = ProductService.GetProduct(productId);

            if (p != null && p.Photo.IsNotEmpty())
            {
                return(String.Format("<img src='{0}'/>", FoldersHelper.GetImageProductPath(ProductImageType.XSmall, p.Photo, true)));
            }

            return(string.Format("<img src='{0}' alt=\"\"/>", AdvantShop.Core.UrlRewriter.UrlService.GetAbsoluteLink("images/nophoto_xsmall.jpg")));
        }
示例#19
0
    protected string RenderPictureTag(ProductItem item)
    {
        string strFormat = "";
        string strResult = "";

        if (string.IsNullOrEmpty(item.Photo))
        {
            strFormat =
                "<div><div onclick=\"location='{0}'\" style=\"cursor:pointer;position:relative;height:90px;width:120px\" title=\"Фотография не доступна\"><img border=\"0\" src=\"images/nophoto_small.jpg\" alt=\"Фотография не доступна\" /></div></div><br/>";
            strResult = string.Format(strFormat, UrlService.GetLinkDB(ParamType.Product, item.ProductId));
        }
        else
        {
            strFormat =
                "<div><div onclick=\"location='{4}'\" style=\"cursor:pointer;position:relative;height:90px;width:120px\" title=\"{0}\"><img class=\"imgPhoto\" border=\"0\" src=\"{1}\" alt=\"{0}\" /></div></div><br/>";
            strResult = string.Format(strFormat, Server.HtmlEncode(item.Name),
                                      FoldersHelper.GetImageProductPath(ProductImageType.Small, item.Photo, false),
                                      item.Photo, "", UrlService.GetLinkDB(ParamType.Product, item.ProductId));
        }
        return(strResult);
    }
示例#20
0
        private static void ProcessProductRow(DataRow row, XmlWriter writer)
        {
            writer.WriteStartElement("offer");
            writer.WriteAttributeString("available", SQLDataHelper.GetBoolean(row["Enabled"]).ToString().ToLower());
            writer.WriteAttributeString("id", row["ArtNo"].ToString());

            writer.WriteStartElement("url");
            if (string.IsNullOrEmpty(HttpContext.Current.Request.Url.Query))
            {
                writer.WriteString(HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "") + "/" + UrlService.GetLink(ParamType.Product, (string)row["UrlPath"], (int)row["ProductID"]));
            }
            else
            {
                writer.WriteString(HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "").Replace(HttpContext.Current.Request.Url.Query, "") + "/" + UrlService.GetLink(ParamType.Product, (string)row["UrlPath"], (int)row["ProductID"]));
            }
            writer.WriteEndElement();


            writer.WriteStartElement("price");
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            writer.WriteString(CatalogService.CalculatePrice(SQLDataHelper.GetDecimal(row["Price"]), SQLDataHelper.GetDecimal(row["discount"])).ToString(nfi));
            writer.WriteEndElement();

            writer.WriteStartElement("currencyId");
            writer.WriteString(_currency);
            writer.WriteEndElement();

            writer.WriteStartElement("categoryId");
            writer.WriteString(row["ParentCategory"].ToString().Replace("ID", ""));
            writer.WriteEndElement();

            writer.WriteStartElement("picture");
            var temp = SQLDataHelper.GetString(row["photo"]);

            if (!string.IsNullOrEmpty(temp))
            {
                if (string.IsNullOrEmpty(HttpContext.Current.Request.Url.Query))
                {
                    writer.WriteString(HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "") + "/" + FoldersHelper.GetImageProductPath(ProductImageType.Middle, temp, false));
                }
                else
                {
                    writer.WriteString(HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "").Replace(HttpContext.Current.Request.Url.Query, "") + "/" + FoldersHelper.GetImageProductPath(ProductImageType.Middle, temp, false));
                }
            }
            writer.WriteEndElement();

            writer.WriteStartElement("name");
            writer.WriteString(SQLDataHelper.GetString(row["Name"]));
            writer.WriteEndElement();

            writer.WriteStartElement("description");
            string desc = SQLDataHelper.GetString(_description == "full" ? row["Description"] : row["BriefDescription"]);

            writer.WriteString(!string.IsNullOrEmpty(desc) ? desc : Resource.ExportFeed_NoDescription);

            writer.WriteEndElement();

            writer.WriteStartElement("sales_notes");
            writer.WriteString(_salesNotes);
            writer.WriteEndElement();

            // расширение от Ritmz
            writer.WriteStartElement("rz_Active");
            writer.WriteString(SQLDataHelper.GetString(row["Enabled"]));
            writer.WriteEndElement();

            writer.WriteStartElement("rz_Quantity");
            writer.WriteString(SQLDataHelper.GetString(row["Amount"]));
            writer.WriteEndElement();

            writer.WriteStartElement("rz_Weight");
            writer.WriteString(SQLDataHelper.GetString(row["Weight"]));
            writer.WriteEndElement();

            writer.WriteStartElement("rz_Length");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();
            writer.WriteStartElement("rz_Width");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();
            writer.WriteStartElement("rz_Height");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();

            writer.WriteStartElement("rz_SupplierName");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();
            writer.WriteStartElement("rz_SupplierCode");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();
            writer.WriteStartElement("rz_SupplierPrice");
            writer.WriteString(SQLDataHelper.GetString(row["SupplyPrice"]));
            writer.WriteEndElement();

            //add fields
            //rz_Active - принимает значение «true», если товар активен и
            //участвует в продажах, «false» - если товар неактивен,
            //даже если количество товара положительное.
            //Значение по умолчанию - «true»;
            //rz_Quantity - cодержит количество товара на складе ИМ в штуках (не обязательное);
            //rz_Weight - cодержит вес товара с упаковкой в килограммах (не обязательное);
            //rz_Length - cодержит длину упаковки в метрах (не обязательное);
            //rz_Width - cодержит ширину упаковки в метрах (не обязательное);
            //rz_Height - содержит высоту упаковки в метрах (не обязательное);
            //rz_SupplierName - наименование поставщика;
            //rz_SupplierCode - код поставщика;
            //rz_SupplierPrice - цена поставщика. Указывается в случае, если
            //требуется получать отчетность по маржинальной
            //прибыли или установить приоритетность выбора
            //поставщиков одного и того же товара по приоритету цены (не обязательное).

            writer.WriteEndElement();
        }
        private string RenderBasketHtml(Customer customer, ShoppingCart shoppingCart)
        {
            if (!shoppingCart.HasItems)
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            sb.Append("<table style=\'width:100%;\' cellspacing=\'0\' cellpadding=\'2\'>");
            sb.Append("<tr>");
            sb.AppendFormat("<td style=\'width:100px; text-align: center;\'>&nbsp;</td>");
            sb.AppendFormat("<td>{0}</td>", Resource.Client_OrderConfirmation_Name);
            sb.AppendFormat("<td style=\'width:90px; text-align:center;\'>{0}</td>", Resource.Client_OrderConfirmation_Price);
            sb.AppendFormat("<td style=\'width:80px; text-align: center;\' >{0}</td>", Resource.Client_OrderConfirmation_Count);
            sb.AppendFormat("<td style=\'width:90px; text-align:center;\'>{0}</td>", Resource.Client_OrderConfirmation_Cost);
            sb.Append("</tr>");

            var      allCurrencies = CurrencyService.GetAllCurrencies(true);
            Currency currency;

            try
            {
                currency = allCurrencies.FirstOrDefault(x => x.Iso3 == SettingsCatalog.DefaultCurrencyIso3) ?? allCurrencies.FirstOrDefault();
            }
            catch (Exception)
            {
                currency = allCurrencies.FirstOrDefault();
            }

            foreach (var item in shoppingCart)
            {
                if (item.Offer != null && item.Offer.Product != null)
                {
                    var photo = item.Offer.Photo;
                    var price = CatalogService.CalculateProductPrice(item.Offer.Price, item.Offer.Product.CalculableDiscount,
                                                                     customer.CustomerGroup, CustomOptionsService.DeserializeFromXml(item.AttributesXml));

                    sb.Append("<tr>");
                    if (photo != null)
                    {
                        sb.AppendFormat("<td style=\'text-align: center;\'><img src='{0}' /></td>",
                                        SettingsMain.SiteUrl.Trim('/') + '/' + FoldersHelper.GetImageProductPath(ProductImageType.XSmall, photo.PhotoName, false));
                    }
                    else
                    {
                        sb.AppendFormat("<td>&nbsp;</td>");
                    }
                    sb.AppendFormat("<td style=\' \'>{0}{1}{2}</td>", item.Offer.Product.Name,
                                    item.Offer.Color != null ? "<div>" + SettingsCatalog.ColorsHeader + ": " + item.Offer.Color.ColorName + "</div>" : "",
                                    item.Offer.Size != null  ? "<div>" + SettingsCatalog.SizesHeader + ": " + item.Offer.Size.SizeName + "</div>" : "");

                    sb.AppendFormat("<td style=\'text-align: center;\'>{0}</td>", CatalogService.GetStringPrice(price, currency));
                    sb.AppendFormat("<td style=\'text-align: center;\'>{0}</td>", item.Amount);
                    sb.AppendFormat("<td style=\'text-align: center;\'>{0}</td>", CatalogService.GetStringPrice(price * item.Amount, currency));
                    sb.Append("</tr>");
                }
            }
            sb.Append("</table>");

            return(sb.ToString());
        }
示例#22
0
        public string GetShoppingCartPopupJson(Offer offer, float amount, bool isSocialTemplate)
        {
            var product = offer.Product;

            var shpCart = ShoppingCartService.CurrentShoppingCart;

            var totalItems    = shpCart.TotalItems;
            var totalDiscount = shpCart.TotalDiscount;
            var totalPrice    = shpCart.TotalPrice;

            var totalCounts = string.Format("{0} {1}",
                                            totalItems == 0 ? "" : totalItems.ToString(CultureInfo.InvariantCulture),
                                            Strings.Numerals(totalItems, Resource.Client_UserControls_ShoppingCart_Empty,
                                                             Resource.Client_UserControls_ShoppingCart_1Product,
                                                             Resource.Client_UserControls_ShoppingCart_2Products,
                                                             Resource.Client_UserControls_ShoppingCart_5Products));

            var customerGroup = CustomerContext.CurrentCustomer.CustomerGroup;

            var showMode = ModuleSettingsProvider.GetSettingValue <string>("showmode", ModuleID);

            var relatedProducts = new List <RelatedProductsModel>();

            if (showMode != "none")
            {
                relatedProducts =
                    ProductService.GetRelatedProducts(product.ProductId, showMode == "related" ? RelatedType.Related : RelatedType.Alternative)
                    .Select(item => new RelatedProductsModel
                {
                    ProductId = item.ProductId,
                    Name      = item.Name,
                    ArtNo     = item.ArtNo,
                    Link      = UrlService.GetLink(ParamType.Product, item.UrlPath, item.ProductId),
                    Price     = CatalogService.RenderPrice(item.MainPrice, item.Discount, true, customerGroup),
                    Photo     = item.Photo != null
                                ? String.Format("<img src='{0}' alt='{1}' class='img-cart' />",
                                                FoldersHelper.GetImageProductPath(ProductImageType.Small, item.Photo, false),
                                                item.PhotoDesc)
                                : "<img src='images/nophoto_xsmall.jpg' alt='' class='img-cart' />",
                    Buttons = GetItemButtons(item)
                }).ToList();
            }


            var obj = new
            {
                status   = "success",
                showCart = true,
                tpl      = "Modules/ShoppingCartPopup/cartpopup.tpl",

                product.Name,
                Sku        = offer.ArtNo,
                TotalItems = totalItems,
                Price      = CatalogService.RenderPrice(offer.Price, product.CalculableDiscount, true, customerGroup),
                Photo      =
                    offer.Photo != null
                        ? String.Format("<img src='{0}' alt='{1}' class='img-cart' />",
                                        FoldersHelper.GetImageProductPath(ProductImageType.Small, offer.Photo.PhotoName, false),
                                        offer.Product.Name)
                        : "<img src='images/nophoto_xsmall.jpg' alt='' class='img-cart' />",

                Link = isSocialTemplate
                            ? "social/detailssocial.aspx?productid=" + product.ProductId
                            : UrlService.GetLink(ParamType.Product, product.UrlPath, product.ProductId),

                ColorHeader = SettingsCatalog.ColorsHeader,
                ColorName   = offer.Color != null ? offer.Color.ColorName : null,
                SizeHeader  = SettingsCatalog.SizesHeader,
                SizeName    = offer.Size != null ? offer.Size.SizeName : null,

                TotalCount = totalCounts,
                TotalPrice = CatalogService.GetStringPrice(totalPrice - totalDiscount > 0 ? totalPrice - totalDiscount : 0),

                RelatedTitle = showMode == "related"
                                    ? SettingsCatalog.RelatedProductName
                                    : SettingsCatalog.AlternativeProductName,
                RelatedProducts = relatedProducts
            };

            return(JsonConvert.SerializeObject(obj));
        }