Skip to content

Commit f3b34af

Browse files
committed
#708 Properly calculating a minimum price for products with tier prices
1 parent 0a5651a commit f3b34af

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

src/Plugins/Nop.Plugin.Feed.GoogleShopping/Description.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Group: Promotion feeds
22
FriendlyName: Google Shopping (formely Google Product Search)
33
SystemName: PromotionFeed.Froogle
4-
Version: 1.76
4+
Version: 1.77
55
SupportedVersions: 3.90
66
Author: nopCommerce team
77
DisplayOrder: 1

src/Plugins/Nop.Plugin.Feed.GoogleShopping/GoogleShoppingService.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,15 @@ public void GenerateFeed(Stream stream, Store store)
353353
decimal finalPriceBase;
354354
if (_googleShoppingSettings.PricesConsiderPromotions)
355355
{
356-
//calculate for the maximum quantity (in case if we have tier prices)
357-
decimal minPossiblePrice = _priceCalculationService.GetFinalPrice(product,
358-
_workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);
356+
var minPossiblePrice = _priceCalculationService.GetFinalPrice(product, _workContext.CurrentCustomer);
357+
358+
if (product.HasTierPrices)
359+
{
360+
//calculate price for the maximum quantity if we have tier prices, and choose minimal
361+
minPossiblePrice = Math.Min(minPossiblePrice,
362+
_priceCalculationService.GetFinalPrice(product, _workContext.CurrentCustomer, quantity: int.MaxValue));
363+
}
364+
359365
decimal taxRate;
360366
finalPriceBase = _taxService.GetProductPrice(product, minPossiblePrice, out taxRate);
361367
}

src/Presentation/Nop.Web/Factories/ProductModelFactory.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,19 @@ protected virtual ProductOverviewModel.ProductPriceModel PrepareProductOverviewP
234234
Product minPriceProduct = null;
235235
foreach (var associatedProduct in associatedProducts)
236236
{
237-
//calculate for the maximum quantity (in case if we have tier prices)
238-
var tmpPrice = _priceCalculationService.GetFinalPrice(associatedProduct,
239-
_workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);
240-
if (!minPossiblePrice.HasValue || tmpPrice < minPossiblePrice.Value)
237+
var tmpMinPossiblePrice = _priceCalculationService.GetFinalPrice(associatedProduct, _workContext.CurrentCustomer);
238+
239+
if (associatedProduct.HasTierPrices)
240+
{
241+
//calculate price for the maximum quantity if we have tier prices, and choose minimal
242+
tmpMinPossiblePrice = Math.Min(tmpMinPossiblePrice,
243+
_priceCalculationService.GetFinalPrice(associatedProduct, _workContext.CurrentCustomer, quantity: int.MaxValue));
244+
}
245+
246+
if (!minPossiblePrice.HasValue || tmpMinPossiblePrice < minPossiblePrice.Value)
241247
{
242248
minPriceProduct = associatedProduct;
243-
minPossiblePrice = tmpPrice;
249+
minPossiblePrice = tmpMinPossiblePrice;
244250
}
245251
}
246252
if (minPriceProduct != null && !minPriceProduct.CustomerEntersPrice)
@@ -330,10 +336,14 @@ protected virtual ProductOverviewModel.ProductPriceModel PrepareProductOverviewP
330336
else
331337
{
332338
//prices
339+
var minPossiblePrice = _priceCalculationService.GetFinalPrice(product, _workContext.CurrentCustomer);
333340

334-
//calculate for the maximum quantity (in case if we have tier prices)
335-
decimal minPossiblePrice = _priceCalculationService.GetFinalPrice(product,
336-
_workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);
341+
if (product.HasTierPrices)
342+
{
343+
//calculate price for the maximum quantity if we have tier prices, and choose minimal
344+
minPossiblePrice = Math.Min(minPossiblePrice,
345+
_priceCalculationService.GetFinalPrice(product, _workContext.CurrentCustomer, quantity: int.MaxValue));
346+
}
337347

338348
decimal taxRate;
339349
decimal oldPriceBase = _taxService.GetProductPrice(product, product.OldPrice, out taxRate);

0 commit comments

Comments
 (0)