Exemple #1
0
        protected string RenderPrice(float productPrice, float discount)
        {
            if (productPrice == 0)
            {
                return(string.Format("<div class=\'price\'>{0}</div>", Resource.Client_Catalog_ContactWithUs));
            }

            string res;

            float price             = CatalogService.CalculateProductPrice(productPrice, discount, Group, null);
            float priceWithDiscount = CatalogService.CalculateProductPrice(productPrice, discount, Group, null);

            if (price.Equals(priceWithDiscount))
            {
                res = string.Format("<div class=\'price\'>{0}</div>", CatalogService.GetStringPrice(price));
            }
            else
            {
                res = string.Format("<div class=\"price-old\">{0}</div><div class=\"price\">{1}</div><div class=\"price-benefit\">{2} {3} {4} {5}% </div>",
                                    CatalogService.GetStringPrice(productPrice),
                                    CatalogService.GetStringPrice(priceWithDiscount),
                                    Resource.Client_Catalog_Discount_Benefit,
                                    CatalogService.GetStringPrice(price - priceWithDiscount),
                                    Resource.Client_Catalog_Discount_Or,
                                    CatalogService.FormatPriceInvariant(discount));
            }

            return(res);
        }
Exemple #2
0
        private void ShowCreditButtons(bool isMultiOffers)
        {
            var creditPayment = PaymentService.GetCreditPaymentMethods().FirstOrDefault();

            if (creditPayment != null && CurrentOffer != null)
            {
                btnAddCredit.Attributes["data-cart-add-productid"] = ProductId.ToString();
                btnAddCredit.Attributes["data-cart-add-offerid"]   = CurrentOffer.OfferId.ToString();
                btnAddCredit.Attributes["data-cart-payment"]       = creditPayment.PaymentMethodId.ToString();
                btnAddCredit.Attributes["data-cart-minprice"]      = creditPayment.MinimumPrice.ToString();

                var productPrice = CatalogService.CalculateProductPrice(CurrentOffer.Price,
                                                                        CurrentProduct.CalculableDiscount,
                                                                        CustomerContext.CurrentCustomer.CustomerGroup,
                                                                        CustomOptionsService.DeserializeFromXml(
                                                                            CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions)));

                var isVisible = productPrice > creditPayment.MinimumPrice && CurrentOffer.Amount > 0;

                ButtonSetVisible(btnAddCredit, isVisible, isMultiOffers);
                ButtonSetVisible(lblFirstPaymentNote, isVisible && creditPayment.MinimumPrice > 0, isMultiOffers);
                ButtonSetVisible(lblFirstPayment, isVisible && creditPayment.MinimumPrice > 0, isMultiOffers);

                hfFirstPaymentPercent.Value = creditPayment.FirstPayment.ToString();

                lblFirstPayment.Text = creditPayment.FirstPayment > 0
                    ? CatalogService.GetStringPrice(productPrice * creditPayment.FirstPayment / 100) + @"*"
                    : string.Format("<div class=\"price\">{0}*</div>", Resource.Client_Details_WithoutFirstPayment);
            }
            else
            {
                ButtonSetVisible(btnAddCredit, false, false);
                ButtonSetVisible(lblFirstPaymentNote, false, false);
                ButtonSetVisible(lblFirstPayment, false, false);
            }
        }
        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());
        }
 private float GetPrice(float price)
 {
     return(CatalogService.CalculateProductPrice(price, Product.Discount, CustomerContext.CurrentCustomer.CustomerGroup, null));
 }