Skip to content

Commit f4fc310

Browse files
committed
Merge branch 'issue-7636-Category-discount-makes-prices-display-three-times' into 4.80-bug-fixes
2 parents 962281a + f41642c commit f4fc310

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -458,28 +458,33 @@ protected virtual async Task<ProductPriceModel> PrepareProductPriceModelAsync(Pr
458458
var finalPriceWithoutDiscount = await _currencyService.ConvertFromPrimaryStoreCurrencyAsync(finalPriceWithoutDiscountBase, currentCurrency);
459459
var finalPriceWithDiscount = await _currencyService.ConvertFromPrimaryStoreCurrencyAsync(finalPriceWithDiscountBase, currentCurrency);
460460

461-
var strikeThroughPrice = decimal.Zero;
462-
461+
model.Price = await _priceFormatter.FormatPriceAsync(finalPriceWithoutDiscount);
463462
if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase > decimal.Zero)
464-
strikeThroughPrice = oldPrice;
465-
466-
if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase)
467-
strikeThroughPrice = finalPriceWithoutDiscount;
468-
469-
if (strikeThroughPrice > decimal.Zero)
470463
{
471-
model.OldPrice = await _priceFormatter.FormatPriceAsync(strikeThroughPrice);
472-
model.OldPriceValue = strikeThroughPrice;
464+
model.OldPrice = await _priceFormatter.FormatPriceAsync(oldPrice);
465+
model.OldPriceValue = oldPrice;
473466
}
474467
else
475468
{
476469
model.OldPrice = null;
477470
model.OldPriceValue = null;
478471
}
479472

480-
model.Price = await _priceFormatter.FormatPriceAsync(finalPriceWithDiscount);
481-
if (hasMultiplePrices)
482-
model.Price = string.Format(await _localizationService.GetResourceAsync("Products.PriceRangeFrom"), model.Price);
473+
if (addPriceRangeFrom)
474+
{
475+
var strikeThroughPrice = decimal.Zero;
476+
477+
if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase)
478+
strikeThroughPrice = finalPriceWithoutDiscount;
479+
480+
if (strikeThroughPrice > decimal.Zero)
481+
{
482+
model.OldPrice = await _priceFormatter.FormatPriceAsync(strikeThroughPrice);
483+
model.OldPriceValue = strikeThroughPrice;
484+
}
485+
486+
model.Price = await _priceFormatter.FormatPriceAsync(finalPriceWithDiscount);
487+
}
483488

484489
if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase)
485490
{
@@ -489,6 +494,9 @@ protected virtual async Task<ProductPriceModel> PrepareProductPriceModelAsync(Pr
489494

490495
model.PriceValue = finalPriceWithDiscount;
491496

497+
if (hasMultiplePrices)
498+
model.Price = string.Format(await _localizationService.GetResourceAsync("Products.PriceRangeFrom"), model.Price);
499+
492500
//property for German market
493501
//we display tax/shipping info only with "shipping enabled" for this product
494502
//we also ensure this it's not free shipping

0 commit comments

Comments
 (0)