Exemple #1
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);
        }
        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));
        }