예제 #1
0
        public static string RenderSelectedOptions(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(string.Empty);
            }
            var result = new StringBuilder("<div class=\"customoptions\">");

            foreach (var item in CustomOptionsService.DeserializeFromXml(xml))
            {
                result.Append(item.CustomOptionTitle);
                result.Append(": ");
                result.Append(item.OptionTitle);
                if (item.OptionPriceBc != 0)
                {
                    result.Append(" ");
                    if (item.OptionPriceBc > 0)
                    {
                        result.Append("+");
                    }
                    result.Append(CatalogService.GetStringPrice(item.OptionPriceBc));
                }
                result.Append("<br />");
            }

            result.Append("</div>");

            return(result.ToString());
        }
예제 #2
0
        public static decimal CalculateProductPrice(decimal price, decimal productDiscount, CustomerGroup customerGroup, IList <EvaluatedCustomOptions> customOptions, bool withProductDiscount)
        {
            decimal customOptionPrice = 0;

            if (customOptions != null)
            {
                customOptionPrice = CustomOptionsService.GetCustomOptionPrice(price, customOptions);
            }

            //Changed by Evgeni to show discount for group and product discount
            decimal finalDiscount = 0;

            if (!withProductDiscount)
            {
                productDiscount = 0;
            }
            else
            {
                decimal groupDiscount = customerGroup.CustomerGroupId == 0 ? 0 : customerGroup.GroupDiscount;

                finalDiscount = Math.Max(productDiscount, groupDiscount);
            }
            //

            return((price + customOptionPrice) * (100 - finalDiscount) / 100);
        }
예제 #3
0
        public static float CalculateProductPrice(float price, float productDiscount, CustomerGroup customerGroup, IList <EvaluatedCustomOptions> customOptions)
        {
            float customOptionPrice = 0;

            if (customOptions != null)
            {
                customOptionPrice = CustomOptionsService.GetCustomOptionPrice(price, customOptions);
            }

            float groupDiscount = customerGroup == null ? 0 : customerGroup.GroupDiscount;
            float finalDiscount = productDiscount > groupDiscount ? productDiscount : groupDiscount;

            return((price + customOptionPrice) * ((100 - finalDiscount) / 100));
        }
예제 #4
0
        public static string RenderPrice(decimal productPrice, decimal discount, bool showDiscount, CustomerGroup customerGroup, string customOptions = null)
        {
            if (productPrice == 0)
            {
                return(string.Format("<div class=\'price\'>{0}</div>", Resource.Client_Catalog_ContactWithUs));
            }
            string res;


            decimal price             = ProductService.CalculateProductPrice(productPrice, discount, customerGroup, CustomOptionsService.DeserializeFromXml(customOptions), false);
            decimal priceWithDiscount = ProductService.CalculateProductPrice(productPrice, discount, customerGroup, CustomOptionsService.DeserializeFromXml(customOptions), true);

            // Added By Evgeni for new price
            string priceForConvertString = CatalogService.GetStringPrice(priceWithDiscount).Replace(CurrencyService.CurrentCurrency.Symbol, "").Replace(" ", "");
            var    newPrice = GenerateNewBelarusPrice(priceForConvertString);

            //

            //Changed by Evgeni to calculate final discount
            decimal groupDiscount = customerGroup.CustomerGroupId == 0 ? 0 : customerGroup.GroupDiscount;

            discount = Math.Max(discount, groupDiscount);
            //


            if (price == priceWithDiscount || !showDiscount)
            {
                res = string.Format("<div class=\'price\'>{0}</div>", (CatalogService.GetStringPrice(priceWithDiscount)));
            }
            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));
            }
            //Added by Evgeni
            res = res + string.Format("<div class=\"price-newformat\">{0}</div>", GenerateNewBelarusPrice(CatalogService.GetStringPrice(priceWithDiscount)));
            return(res);
        }
예제 #5
0
        public static string RenderBonusPrice(float bonusPercent, float productPrice, float discount,
                                              CustomerGroup customerGroup, string customOptions = null)
        {
            var priceWithDiscount = CalculateProductPrice(productPrice, discount, customerGroup, CustomOptionsService.DeserializeFromXml(customOptions));

            if (productPrice <= 0 || bonusPercent <= 0 || priceWithDiscount <= 0)
            {
                return(string.Empty);
            }

            return(String.Format("<div class=\"bonus-price\">" + Resource.Client_Bonuses_BonusesOnCard + "</div>",
                                 GetStringPrice(priceWithDiscount * bonusPercent / 100)));
        }
예제 #6
0
        /// <summary>
        /// Render price with inplace editor
        /// </summary>
        /// <param name="productPrice">product price</param>
        /// <param name="discount">total discount price</param>
        /// <param name="showDiscount">display discount</param>
        /// <param name="customerGroup">customer group</param>
        /// <param name="customOptions">custom options</param>
        /// <param name="offerId">offer id</param>
        /// <returns></returns>
        public static string RenderPriceInplace(float productPrice, float discount, bool showDiscount,
                                                CustomerGroup customerGroup, string customOptions = null, int offerId = 0)
        {
            if (productPrice == 0)
            {
                return(String.Format("<div class=\'price-wrap\' {1}>{0}</div>", Resource.Client_Catalog_ContactWithUs,
                                     InplaceEditor.Offer.AttributePriceDetails(offerId, InplaceEditor.Offer.Field.Price)));
            }

            float priceWithCustomOptions = CalculateProductPrice(productPrice, 0, null, CustomOptionsService.DeserializeFromXml(customOptions));

            var priceWithDiscount = CalculateProductPrice(productPrice, discount, customerGroup, CustomOptionsService.DeserializeFromXml(customOptions));

            if (discount == 0 || !showDiscount)
            {
                return(String.Format("<div class=\'price-wrap inplace-indicator-offset {1}\'>{0}</div>",
                                     GetStringPriceInplace(priceWithDiscount, InplaceEditor.Offer.Field.Price, offerId),
                                     !SettingsMain.EnableInplace ? "inplace-indicator-offset-off" : ""));
            }

            var groupDiscount = customerGroup.CustomerGroupId == 0 ? 0 : customerGroup.GroupDiscount;
            var finalDiscount = Math.Max(discount, groupDiscount);

            return
                (String.Format(
                     "<div class=\"price-old inplace-indicator-offset\">{0}</div><div class=\"price-wrap\">{1}</div><div class=\"price-benefit\">{2} {3} {4} {5}% </div>",
                     GetStringPriceInplace(priceWithCustomOptions, InplaceEditor.Offer.Field.Price, offerId),
                     GetStringPrice(priceWithDiscount, isMainPrice: true),
                     Resource.Client_Catalog_Discount_Benefit,
                     GetStringPrice(priceWithCustomOptions - priceWithDiscount),
                     Resource.Client_Catalog_Discount_Or,
                     FormatPriceInvariant(finalDiscount)));
        }
예제 #7
0
        /// <summary>
        /// Render product price
        /// </summary>
        /// <param name="productPrice">product price</param>
        /// <param name="discount">total discount price</param>
        /// <param name="showDiscount">display discount</param>
        /// <param name="customerGroup">customer group</param>
        /// <param name="customOptions">custom options</param>
        /// <param name="isWrap">currency wrap</param>
        /// <returns></returns>
        public static string RenderPrice(float productPrice, float discount, bool showDiscount, CustomerGroup customerGroup,
                                         string customOptions = null, bool isWrap = false)
        {
            if (productPrice == 0)
            {
                return(String.Format("<div class='price-wrap'>{0}</div>", Resource.Client_Catalog_ContactWithUs));
            }

            float priceWithCustomOptions = CalculateProductPrice(productPrice, 0, null, CustomOptionsService.DeserializeFromXml(customOptions));

            var priceWithDiscount = CalculateProductPrice(productPrice, discount, customerGroup, CustomOptionsService.DeserializeFromXml(customOptions));

            if (discount == 0 || !showDiscount)
            {
                return(String.Format("<div class='price-wrap'>{0}</div>", GetStringPrice(priceWithDiscount, isWrap)));
            }

            var groupDiscount = customerGroup.CustomerGroupId == 0 ? 0 : customerGroup.GroupDiscount;
            var finalDiscount = discount > groupDiscount ? discount : groupDiscount;

            return
                (String.Format(
                     "<div class=\"price-old\">{0}</div><div class=\"price-wrap\">{1}</div><div class=\"price-benefit\">{2} {3} {4} {5}% </div>",
                     GetStringPrice(priceWithCustomOptions),
                     GetStringPrice(priceWithDiscount, isMainPrice: true),
                     Resource.Client_Catalog_Discount_Benefit,
                     GetStringPrice(priceWithCustomOptions - priceWithDiscount),
                     Resource.Client_Catalog_Discount_Or,
                     FormatPriceInvariant(finalDiscount)));
        }