Skip to content

Commit

Permalink
Resolves #1210 Add a setting to not apply a discount associated with …
Browse files Browse the repository at this point in the history
…a product when the special price of the product is applied
  • Loading branch information
mgesing committed Nov 8, 2024
1 parent c75b619 commit 5dbbb29
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- #1176 Avoid duplicate assignment of description on the product page.
- #528 Add an option to no longer allow posts on a forum topic.
- #1204 Added settings to enable/disable the RSS feed in blogs and news.
- #1210 Add a setting to not apply a discount associated with a product when the special price of the product is applied.

### Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public class PriceSettings : ISettings
/// </summary>
public bool ApplyPriceRangeFormatInProductDetails { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to ignore discounts assigned to products when a special price is applied.
/// </summary>
public bool IgnoreProductDiscountsForSpecialPrices { get; set; }

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected virtual async Task<ICollection<Discount>> GetApplicableDiscountsAsync(

// Check discounts assigned to the product.
// We use the property "HasDiscountsApplied" for performance optimization to avoid unnecessary database calls.
if (product.HasDiscountsApplied)
if (product.HasDiscountsApplied && !(_priceSettings.IgnoreProductDiscountsForSpecialPrices && context.OfferPrice != null))
{
var collectionLoaded = _db.IsCollectionLoaded(product, x => x.AppliedDiscounts);
var appliedDiscounts = collectionLoaded ? product.AppliedDiscounts : await batchContext.AppliedDiscounts.GetOrLoadAsync(product.Id);
Expand Down
6 changes: 6 additions & 0 deletions src/Smartstore.Core/Migrations/SmartDbContextDataSeeder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,12 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
"Specifies whether the price is displayed with the suffix \"from\" if no variant has yet been selected in product details.",
"Legt fest, ob der Preis mit dem Zusatz \"ab\" angezeigt wird, wenn in den Produktdetails noch keine Variante ausgewählt wurde.");

builder.AddOrUpdate("Admin.Configuration.Settings.Price.IgnoreProductDiscountsForSpecialPrices",
"Ignore product discounts for special prices",
"Produktrabatte bei Aktionspreisen ignorieren",
"Specifies whether to ignore discounts assigned to products when a special price is applied.",
"Legt fest, ob produktbezogene Rabatte ignoriert werden, wenn ein Aktionspreis gilt.");

AddAIResources(builder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public class PriceSettingsModel : ModelBase
[LocalizedDisplay("*ApplyPriceRangeFormatInProductDetails")]
public bool ApplyPriceRangeFormatInProductDetails { get; set; }

[LocalizedDisplay("*IgnoreProductDiscountsForSpecialPrices")]
public bool IgnoreProductDiscountsForSpecialPrices { get; set; }

#endregion
}

Expand Down
9 changes: 9 additions & 0 deletions src/Smartstore.Web/Areas/Admin/Views/Setting/Price.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@
<span asp-validation-for="PriceSettings.ValidateDiscountGiftCardsInLists"></span>
</div>
</div>
<div class="adminRow pricing-discounts">
<div class="adminTitle">
<smart-label asp-for="PriceSettings.IgnoreProductDiscountsForSpecialPrices" />
</div>
<div class="adminData">
<setting-editor asp-for="PriceSettings.IgnoreProductDiscountsForSpecialPrices"></setting-editor>
<span asp-validation-for="PriceSettings.IgnoreProductDiscountsForSpecialPrices"></span>
</div>
</div>
<div class="adminRow pricing-discounts">
<div class="adminTitle">
<smart-label asp-for="PriceSettings.ApplyPercentageDiscountOnTierPrice" />
Expand Down

0 comments on commit 5dbbb29

Please sign in to comment.