Skip to content

Commit

Permalink
#2201 New "GetPreferredTierPrice" method should return "TierPrice" en…
Browse files Browse the repository at this point in the history
…tity
  • Loading branch information
AndreiMaz committed Mar 8, 2017
1 parent 4180b26 commit 35d874a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Expand Up @@ -393,7 +393,9 @@ protected virtual IList<DiscountForCaching> GetAllowedDiscounts(Product product,
decimal price = overriddenProductPrice.HasValue ? overriddenProductPrice.Value : product.Price;
//tier prices
price = product.GetPreferredTierPrice(customer, _storeContext.CurrentStore.Id, quantity) ?? price;
var tierPrice = product.GetPreferredTierPrice(customer, _storeContext.CurrentStore.Id, quantity);
if (tierPrice != null)
price = tierPrice.Price;
//additional charge
price = price + additionalCharge;
Expand Down
7 changes: 3 additions & 4 deletions src/Libraries/Nop.Services/Catalog/ProductExtensions.cs
Expand Up @@ -22,8 +22,8 @@ public static class ProductExtensions
/// <param name="customer">Customer</param>
/// <param name="storeId">Store identifier</param>
/// <param name="quantity">Quantity</param>
/// <returns>Price</returns>
public static decimal? GetPreferredTierPrice(this Product product, Customer customer, int storeId, int quantity)
/// <returns>Tier price</returns>
public static TierPrice GetPreferredTierPrice(this Product product, Customer customer, int storeId, int quantity)
{
if (!product.HasTierPrices)
return null;
Expand All @@ -37,8 +37,7 @@ public static class ProductExtensions

//get the most suitable tier price based on the passed quantity
var tierPrice = actualTierPrices.LastOrDefault(price => quantity >= price.Quantity);

return tierPrice != null ? (decimal?)tierPrice.Price : null;
return tierPrice;
}

/// <summary>
Expand Down

0 comments on commit 35d874a

Please sign in to comment.