forked from nopSolutions/nopCommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notification to vendor when order cancelled nopSolutions#7108
- Loading branch information
1 parent
d31bc90
commit 3fa485b
Showing
10 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Libraries/Nop.Data/Migrations/UpdateTo480/DataMigration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using FluentMigrator; | ||
using Nop.Core.Domain.Messages; | ||
|
||
namespace Nop.Data.Migrations.UpdateTo480 | ||
{ | ||
[NopMigration("2024-05-09 00:00:00", "4.80.0", UpdateMigrationType.Data, MigrationProcessType.Update)] | ||
public class DataMigration : Migration | ||
{ | ||
private readonly INopDataProvider _dataProvider; | ||
|
||
public DataMigration(INopDataProvider dataProvider) | ||
{ | ||
_dataProvider = dataProvider; | ||
} | ||
|
||
/// <summary> | ||
/// Collect the UP migration expressions | ||
/// </summary> | ||
public override void Up() | ||
{ | ||
|
||
//#7108 New message template | ||
if (!_dataProvider.GetTable<MessageTemplate>().Any(st => string.Compare(st.Name, MessageTemplateSystemNames.ORDER_CANCELLED_VENDOR_NOTIFICATION, StringComparison.InvariantCultureIgnoreCase) == 0)) | ||
{ | ||
var eaGeneral = _dataProvider.GetTable<EmailAccount>().FirstOrDefault() ?? throw new Exception("Default email account cannot be loaded"); | ||
_dataProvider.InsertEntity(new MessageTemplate() | ||
{ | ||
Name = MessageTemplateSystemNames.ORDER_CANCELLED_VENDOR_NOTIFICATION, | ||
Subject = "%Store.Name%. Order #%Order.OrderNumber% cancelled", | ||
Body = $"<p>{Environment.NewLine}<a href=\"%Store.URL%\">%Store.Name%</a>{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}Order #%Order.OrderNumber% has been cancelled.{Environment.NewLine}<br />{Environment.NewLine}Customer: %Order.CustomerFullName%,{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}Order Number: %Order.OrderNumber%{Environment.NewLine}<br />{Environment.NewLine}Date Ordered: %Order.CreatedOn%{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}%Order.Product(s)%{Environment.NewLine}</p>{Environment.NewLine}", | ||
IsActive = true, | ||
EmailAccountId = eaGeneral.Id | ||
}); | ||
} | ||
} | ||
|
||
public override void Down() | ||
{ | ||
//add the downgrade logic if necessary | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Presentation/Nop.Web.Framework/Migrations/UpgradeTo480/LocalizationMigration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using FluentMigrator; | ||
using Nop.Core.Infrastructure; | ||
using Nop.Data; | ||
using Nop.Data.Migrations; | ||
using Nop.Services.Localization; | ||
using Nop.Web.Framework.Extensions; | ||
|
||
namespace Nop.Web.Framework.Migrations.UpgradeTo480 | ||
{ | ||
[NopMigration("2024-05-09 00:00:00", "4.80.0", UpdateMigrationType.Localization, MigrationProcessType.Update)] | ||
public class LocalizationMigration : MigrationBase | ||
{ | ||
/// <summary>Collect the UP migration expressions</summary> | ||
public override void Up() | ||
{ | ||
if (!DataSettingsManager.IsDatabaseInstalled()) | ||
return; | ||
|
||
//do not use DI, because it produces exception on the installation process | ||
var localizationService = EngineContext.Current.Resolve<ILocalizationService>(); | ||
|
||
var (languageId, languages) = this.GetLanguageData(); | ||
|
||
#region Delete locales | ||
|
||
#endregion | ||
|
||
#region Rename locales | ||
|
||
#endregion | ||
|
||
#region Add or update locales | ||
|
||
localizationService.AddOrUpdateLocaleResource(new Dictionary<string, string> | ||
{ | ||
//#7108 | ||
["Admin.ContentManagement.MessageTemplates.Description.OrderCancelled.VendorNotification"] = "This message template is used to notify a vendor that the certain order was cancelled.The order can be cancelled by a customer on the account page or by store owner in Customers - Customers in Orders tab or in Sales - Orders.", | ||
}, languageId); | ||
|
||
#endregion | ||
} | ||
|
||
/// <summary>Collects the DOWN migration expressions</summary> | ||
public override void Down() | ||
{ | ||
//add the downgrade logic if necessary | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Presentation/Nop.Web.Framework/Migrations/UpgradeTo480/SettingMigration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using FluentMigrator; | ||
using Nop.Core.Infrastructure; | ||
using Nop.Data; | ||
using Nop.Data.Migrations; | ||
using Nop.Services.Configuration; | ||
|
||
namespace Nop.Web.Framework.Migrations.UpgradeTo480 | ||
{ | ||
[NopMigration("2024-05-09 00:00:00", "4.80.0", UpdateMigrationType.Settings, MigrationProcessType.Update)] | ||
public class SettingMigration : MigrationBase | ||
{ | ||
/// <summary>Collect the UP migration expressions</summary> | ||
public override void Up() | ||
{ | ||
if (!DataSettingsManager.IsDatabaseInstalled()) | ||
return; | ||
|
||
//do not use DI, because it produces exception on the installation process | ||
var settingService = EngineContext.Current.Resolve<ISettingService>(); | ||
} | ||
|
||
public override void Down() | ||
{ | ||
//add the downgrade logic if necessary | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters