Skip to content

Commit b3aa5b4

Browse files
committed
Fix bug with tier pricing
1 parent 7af921a commit b3aa5b4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

STOREFRONT/VirtoCommerce.Storefront.Model/Catalog/Product.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public void ApplyPrices(IEnumerable<ProductPrice> prices, Currency currentCurren
253253
var orderedPrices = currencyGroup.OrderBy(x => x.MinQuantity ?? 0).ThenBy(x => x.ListPrice);
254254
var nominalPrice = orderedPrices.FirstOrDefault();
255255
//and add to nominal price other prices as tier prices
256-
nominalPrice.TierPrices.AddRange(orderedPrices.Select(x => new TierPrice(x.SalePrice, x.MinQuantity ?? 0)));
256+
nominalPrice.TierPrices.AddRange(orderedPrices.Select(x => new TierPrice(x.SalePrice, x.MinQuantity ?? 1)));
257257
//Add nominal price to product prices list
258258
Prices.Add(nominalPrice);
259259
}
@@ -268,6 +268,7 @@ public void ApplyPrices(IEnumerable<ProductPrice> prices, Currency currentCurren
268268
if (Prices.Any())
269269
{
270270
price = Prices.First().ConvertTo(currency);
271+
price.TierPrices.Add(new TierPrice(price.SalePrice, 1));
271272
}
272273
Prices.Add(price);
273274
}

STOREFRONT/VirtoCommerce.Storefront.Model/Catalog/ProductPrice.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ public Money ActualPrice
112112
/// <returns></returns>
113113
public TierPrice GetTierPrice(int quantity)
114114
{
115-
var retVal = TierPrices.OrderBy(x => x.Quantity).Last(x => x.Quantity <= quantity);
115+
var retVal = TierPrices.OrderBy(x => x.Quantity).LastOrDefault(x => x.Quantity <= quantity);
116+
if(retVal == null)
117+
{
118+
retVal = new TierPrice(SalePrice, 1);
119+
}
116120
return retVal;
117121
}
118122

0 commit comments

Comments
 (0)