当前位置: 首页>>代码示例>>C#>>正文


C# IPriceCalculationService.GetFinalPrice方法代码示例

本文整理汇总了C#中IPriceCalculationService.GetFinalPrice方法的典型用法代码示例。如果您正苦于以下问题:C# IPriceCalculationService.GetFinalPrice方法的具体用法?C# IPriceCalculationService.GetFinalPrice怎么用?C# IPriceCalculationService.GetFinalPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPriceCalculationService的用法示例。


在下文中一共展示了IPriceCalculationService.GetFinalPrice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBasePriceInfo

        /// <summary>
        /// Gets the base price
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="localizationService">Localization service</param>
        /// <param name="priceFormatter">Price formatter</param>
        /// <param name="priceAdjustment">Price adjustment</param>
        /// <param name="languageIndependent">Whether the result string should be language independent</param>
        /// <returns>The base price</returns>
        public static string GetBasePriceInfo(this Product product, ILocalizationService localizationService, IPriceFormatter priceFormatter,
            ICurrencyService currencyService, ITaxService taxService, IPriceCalculationService priceCalculationService,
            Currency currency, decimal priceAdjustment = decimal.Zero, bool languageIndependent = false)
        {
            if (product == null)
                throw new ArgumentNullException("product");

            if (localizationService == null && !languageIndependent)
                throw new ArgumentNullException("localizationService");

            if (product.BasePriceHasValue && product.BasePriceAmount != Decimal.Zero)
            {
                var workContext = EngineContext.Current.Resolve<IWorkContext>();

                var taxrate = decimal.Zero;
                var currentPrice = priceCalculationService.GetFinalPrice(product, workContext.CurrentCustomer, true);
                decimal price = taxService.GetProductPrice(product, decimal.Add(currentPrice, priceAdjustment), out taxrate);

                price = currencyService.ConvertFromPrimaryStoreCurrency(price, currency);

                decimal basePriceValue = Convert.ToDecimal((price / product.BasePriceAmount) * product.BasePriceBaseAmount);

                string basePrice = priceFormatter.FormatPrice(basePriceValue, true, currency);
                string unit = "{0} {1}".FormatWith(product.BasePriceBaseAmount, product.BasePriceMeasureUnit);

                if (languageIndependent)
                {
                    return "{0} / {1}".FormatWith(basePrice, unit);
                }

                return localizationService.GetResource("Products.BasePriceInfo").FormatWith(basePrice, unit);
            }
            return "";
        }
开发者ID:mandocaesar,项目名称:Mesinku,代码行数:43,代码来源:ProductExtensions.cs

示例2: PrepareProductOverviewModels

        public static IEnumerable<ProductOverviewModel> PrepareProductOverviewModels(this Controller controller,
            IWorkContext workContext,
            IStoreContext storeContext,
            ICategoryService categoryService,
            IProductService productService,
            ISpecificationAttributeService specificationAttributeService,
            IPriceCalculationService priceCalculationService,
            IPriceFormatter priceFormatter,
            IPermissionService permissionService,
            ILocalizationService localizationService,
            ITaxService taxService,
            ICurrencyService currencyService,
            IPictureService pictureService,
            IWebHelper webHelper,
            ICacheManager cacheManager,
            CatalogSettings catalogSettings,
            MediaSettings mediaSettings,
            IEnumerable<Product> products,
            bool preparePriceModel = true, bool preparePictureModel = true,
            int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false,
            bool forceRedirectionAfterAddingToCart = false)
        {
            if (products == null)
                throw new ArgumentNullException("products");

            var models = new List<ProductOverviewModel>();
            foreach (var product in products)
            {
                var model = new ProductOverviewModel
                {
                    Id = product.Id,
                    Name = product.GetLocalized(x => x.Name),
                    ShortDescription = product.GetLocalized(x => x.ShortDescription),
                    FullDescription = product.GetLocalized(x => x.FullDescription),
                    SeName = product.GetSeName(),
                };
                //price
                if (preparePriceModel)
                {
                    #region Prepare product price

                    var priceModel = new ProductOverviewModel.ProductPriceModel
                    {
                        ForceRedirectionAfterAddingToCart = forceRedirectionAfterAddingToCart
                    };

                    switch (product.ProductType)
                    {
                        case ProductType.GroupedProduct:
                            {
                                #region Grouped product

                                var associatedProducts = productService.GetAssociatedProducts(product.Id, storeContext.CurrentStore.Id);

                                switch (associatedProducts.Count)
                                {
                                    case 0:
                                        {
                                            //no associated products
                                            //priceModel.DisableBuyButton = true;
                                            //priceModel.DisableWishlistButton = true;
                                            //compare products
                                            priceModel.DisableAddToCompareListButton = !catalogSettings.CompareProductsEnabled;
                                            //priceModel.AvailableForPreOrder = false;
                                        }
                                        break;
                                    default:
                                        {
                                            //we have at least one associated product
                                            //priceModel.DisableBuyButton = true;
                                            //priceModel.DisableWishlistButton = true;
                                            //compare products
                                            priceModel.DisableAddToCompareListButton = !catalogSettings.CompareProductsEnabled;
                                            //priceModel.AvailableForPreOrder = false;

                                            if (permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
                                            {
                                                //find a minimum possible price
                                                decimal? minPossiblePrice = null;
                                                Product minPriceProduct = null;
                                                foreach (var associatedProduct in associatedProducts)
                                                {
                                                    //calculate for the maximum quantity (in case if we have tier prices)
                                                    var tmpPrice = priceCalculationService.GetFinalPrice(associatedProduct,
                                                        workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);
                                                    if (!minPossiblePrice.HasValue || tmpPrice < minPossiblePrice.Value)
                                                    {
                                                        minPriceProduct = associatedProduct;
                                                        minPossiblePrice = tmpPrice;
                                                    }
                                                }
                                                if (minPriceProduct != null && !minPriceProduct.CustomerEntersPrice)
                                                {
                                                    if (minPriceProduct.CallForPrice)
                                                    {
                                                        priceModel.OldPrice = null;
                                                        priceModel.Price = localizationService.GetResource("Products.CallForPrice");
                                                    }
                                                    else if (minPossiblePrice.HasValue)
                                                    {
//.........这里部分代码省略.........
开发者ID:rajendra1809,项目名称:nopCommerce,代码行数:101,代码来源:ControllerExtensions.cs

示例3: GetBasePriceInfo

        /// <summary>
        /// Gets the base price info
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="localizationService">Localization service</param>
        /// <param name="priceFormatter">Price formatter</param>
        /// <param name="currencyService">Currency service</param>
        /// <param name="taxService">Tax service</param>
        /// <param name="priceCalculationService">Price calculation service</param>
        /// <param name="currency">Target currency</param>
        /// <param name="priceAdjustment">Price adjustment</param>
        /// <param name="languageInsensitive">Whether the result string should be language insensitive</param>
        /// <returns>The base price info</returns>
        public static string GetBasePriceInfo(this Product product,
			ILocalizationService localizationService,
			IPriceFormatter priceFormatter,
            ICurrencyService currencyService,
			ITaxService taxService,
			IPriceCalculationService priceCalculationService,
            Currency currency,
			decimal priceAdjustment = decimal.Zero,
			bool languageInsensitive = false)
        {
            Guard.ArgumentNotNull(() => product);
            Guard.ArgumentNotNull(() => currencyService);
            Guard.ArgumentNotNull(() => taxService);
            Guard.ArgumentNotNull(() => priceCalculationService);
            Guard.ArgumentNotNull(() => currency);

            if (product.BasePriceHasValue && product.BasePriceAmount != Decimal.Zero)
            {
                var workContext = EngineContext.Current.Resolve<IWorkContext>();

                var taxrate = decimal.Zero;
                var currentPrice = priceCalculationService.GetFinalPrice(product, workContext.CurrentCustomer, true);
                var price = taxService.GetProductPrice(product, decimal.Add(currentPrice, priceAdjustment), out taxrate);

                price = currencyService.ConvertFromPrimaryStoreCurrency(price, currency);

                return product.GetBasePriceInfo(price, localizationService, priceFormatter, currency, languageInsensitive);
            }

            return "";
        }
开发者ID:toannguyen241994,项目名称:SmartStoreNET,代码行数:44,代码来源:ProductExtensions.cs


注:本文中的IPriceCalculationService.GetFinalPrice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。