diff --git a/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs b/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs index d3afcd3b8..a390cbeec 100644 --- a/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs +++ b/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs @@ -559,10 +559,10 @@ async Task PrepareModel() } } } + //summarize price of all attributes + double attributesTotalPrice = 0; if (!finalPrice.HasValue) - { - //summarize price of all attributes - double attributesTotalPrice = 0; + { if (attributes != null && attributes.Any()) { var attributeValues = product.ParseProductAttributeValues(attributes); @@ -587,34 +587,36 @@ async Task PrepareModel() } } } - if (!product.EnteredPrice) + } + + if (!product.EnteredPrice) + { + var qty = 0; + if (_shoppingCartSettings.GroupTierPrices) { - var qty = 0; - if (_shoppingCartSettings.GroupTierPrices) - { - qty = customer.ShoppingCartItems - .Where(x => x.ProductId == product.Id) - .Where(x => x.ShoppingCartTypeId == shoppingCartType) - .Sum(x => x.Quantity); - } - if (qty == 0) - qty = quantity; - - var getfinalPrice = await GetFinalPrice(product, - customer, - currency, - attributesTotalPrice, - includeDiscounts, - qty, - rentalStartDate, - rentalEndDate); - - finalPrice = getfinalPrice.finalPrice; - discountAmount = getfinalPrice.discountAmount; - appliedDiscounts = getfinalPrice.appliedDiscounts; + qty = customer.ShoppingCartItems + .Where(x => x.ProductId == product.Id) + .Where(x => x.ShoppingCartTypeId == shoppingCartType) + .Sum(x => x.Quantity); } + if (qty == 0) + qty = quantity; + + var getfinalPrice = await GetFinalPrice(product, + customer, + currency, + finalPrice ??= 0 + attributesTotalPrice, + includeDiscounts, + qty, + rentalStartDate, + rentalEndDate); + + finalPrice = getfinalPrice.finalPrice; + discountAmount = getfinalPrice.discountAmount; + appliedDiscounts = getfinalPrice.appliedDiscounts; } + finalPrice ??= 0; //rounding