Conversation
An hourly task e-mails the customer of each booked order item once, the store's ReservationReminderHoursBefore (default 24, 0 = off) before it begins. Reservations ordered within that window or already begun get no reminder; a day range is reminded once, by its first day.
| RentalStartDateUtc = new DateTime(2026, 12, 14, 23, 0, 0, DateTimeKind.Utc), | ||
| RentalEndDateUtc = new DateTime(2026, 12, 16, 23, 0, 0, DateTimeKind.Utc) | ||
| }; | ||
| var reservation = new ProductReservation { Date = orderItem.RentalStartDateUtc.Value, Resource = "Tent <1>" }; |
| _shoppingCartSettings.ReservationDateFormat = "yyyy-MM-dd HH:mm"; | ||
| var orderItem = new OrderItem { RentalStartDateUtc = new DateTime(2026, 12, 15, 9, 0, 0, DateTimeKind.Utc) }; | ||
| var reservation = new ProductReservation { | ||
| Date = orderItem.RentalStartDateUtc.Value, Parameter = "Court 2", Duration = "1 hour" |
Comment on lines
+38
to
+42
| catch (Exception ex) | ||
| { | ||
| logService.LogError(ex, "UpgradeProcess - ReservationReminders {Step} (2.5)", name); | ||
| success = false; | ||
| } |
| private static readonly DateTime Now = new(2026, 12, 10, 8, 0, 0, DateTimeKind.Utc); | ||
|
|
||
| private readonly Dictionary<string, int> _hoursBefore = new() { ["store1"] = 24 }; | ||
| private Mock<IOrderMessageProviderService> _messageServiceMock; |
|
|
||
| private readonly Dictionary<string, int> _hoursBefore = new() { ["store1"] = 24 }; | ||
| private Mock<IOrderMessageProviderService> _messageServiceMock; | ||
| private IRepository<Order> _orderRepository; |
| private readonly Dictionary<string, int> _hoursBefore = new() { ["store1"] = 24 }; | ||
| private Mock<IOrderMessageProviderService> _messageServiceMock; | ||
| private IRepository<Order> _orderRepository; | ||
| private Mock<IOrderService> _orderServiceMock; |
| private Mock<IOrderMessageProviderService> _messageServiceMock; | ||
| private IRepository<Order> _orderRepository; | ||
| private Mock<IOrderService> _orderServiceMock; | ||
| private IRepository<ProductReservation> _reservationRepository; |
| private IRepository<Order> _orderRepository; | ||
| private Mock<IOrderService> _orderServiceMock; | ||
| private IRepository<ProductReservation> _reservationRepository; | ||
| private ReservationReminderService _service; |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved reminder-handling bugs can permanently suppress valid booking reminders, and unbounded settings can halt reminder processing across all stores.
5 open issues
Bound reminder hours to prevent invalid date calculations · New Do not mark reminders handled before the order is persisted · New Resolve legacy reservations by date before marking them handled · New Constrain booking updates to reservation date ranges · New Avoid reservation links unavailable to reminder recipients · New
What changed in this PR
Adds reservation reminder emails to the existing scheduling and messaging systems, linking customers to the reservations page introduced in #1168.
Changes:
- Adds hourly reminders with per-store timing and handled-booking tracking.
- Adds reservation email tokens, templates, installer defaults, and an upgrade migration.
- Exposes settings in Admin and Store and adds regression tests.
Review used source inspection only; tests and builds were not run.
| File | Description |
|---|---|
| src/Web/Grand.Web/App_Data/Resources/Upgrade/en_250.xml | Adds reminder setting translations. |
| src/Web/Grand.Web.Store/Areas/Store/Views/Setting/Partials/Sales.TabShoppingCart.cshtml | Exposes the Store setting. |
| src/Web/Grand.Web.AdminShared/Models/Settings/SalesSettingsModel.cs | Adds the shared setting field. |
| src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Partials/Sales.TabShoppingCart.cshtml | Exposes the Admin setting. |
| src/Tests/Grand.Modules.Tests/Services/Migrations/MigrationReservationRemindersTests.cs | Tests migration idempotency and template parity. |
| src/Tests/Grand.Modules.Tests/Services/BackgroundService/ReservationReminderScheduleTaskTests.cs | Tests task delegation. |
| src/Tests/Grand.Modules.Tests/Installer/MessageTemplateSeedTests.cs | Updates expected template count. |
| src/Tests/Grand.Mapping.Tests/AdminShared/SettingsMappingTests.ShoppingCartSettings_ToModel.verified.txt | Updates the settings snapshot. |
| src/Tests/Grand.Business.Messages.Tests/Commands/GetReservationTokensCommandHandlerTests.cs | Tests reservation tokens and formatting. |
| src/Tests/Grand.Business.Checkout.Tests/Services/Orders/ReservationReminderServiceTests.cs | Tests reminder eligibility and retries. |
| src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReservationServiceTests.cs | Tests stamp clearing on rebooking. |
| src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs | Registers the scheduled task. |
| src/Modules/Grand.Module.ScheduledTasks/BackgroundServices/ReservationReminderScheduleTask.cs | Invokes the reminder service. |
| src/Modules/Grand.Module.Migration/Migrations/2.5/MigrationReservationReminders.cs | Adds the task and template during upgrade. |
| src/Modules/Grand.Module.Installer/Services/MessageTemplates/MessageTemplateSeed.Reservations.cs | Defines the reminder template. |
| src/Modules/Grand.Module.Installer/Services/MessageTemplates/MessageTemplateSeed.cs | Includes reservation templates. |
| src/Modules/Grand.Module.Installer/Services/InstallDataSettings.cs | Seeds the 24-hour default. |
| src/Modules/Grand.Module.Installer/Services/InstallDataScheduleTasks.cs | Seeds the enabled hourly task. |
| src/Core/Grand.Domain/Orders/ShoppingCartSettings.cs | Defines the reminder window setting. |
| src/Core/Grand.Domain/Messages/LiquidObject.cs | Exposes reservation tokens. |
| src/Core/Grand.Domain/Catalog/ProductReservation.cs | Stores the handled timestamp. |
| src/Business/Grand.Business.Messages/Services/OrderMessageProviderService.cs | Queues reservation reminder emails. |
| src/Business/Grand.Business.Messages/Services/MessageTemplateNames.cs | Defines the template identifier. |
| src/Business/Grand.Business.Messages/DotLiquidDrops/LiquidReservation.cs | Defines reservation email fields. |
| src/Business/Grand.Business.Messages/DotLiquidDrops/LiquidObjectBuilder.cs | Integrates reservation token generation. |
| src/Business/Grand.Business.Messages/Commands/Tokens/GetReservationTokensCommand.cs | Carries token-generation inputs. |
| src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetReservationTokensCommandHandler.cs | Formats reservation details and links. |
| src/Business/Grand.Business.Core/Interfaces/Messages/IOrderMessageProviderService.cs | Adds the reminder message contract. |
| src/Business/Grand.Business.Core/Interfaces/Checkout/Orders/IReservationReminderService.cs | Defines the reminder service contract. |
| src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs | Registers the reminder service. |
| src/Business/Grand.Business.Checkout/Services/Orders/ReservationReminderService.cs | Selects bookings, sends reminders, and stamps slots. |
| src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.cs | Clears reminder stamps when rebooking. |
| bash.exe.stackdump | Adds unrelated shell diagnostics. |
| .ai/skills/scheduled-task.md | Documents the new scheduled task. |
Review effort: Balanced
|
|
||
| //the booked slots beginning within the longest window of all stores, not handled yet; a slot carries no store, | ||
| //so each store's own window is applied to the order. Only the slots of the next hours are read | ||
| var until = utcNow.AddHours(longest); |
| try | ||
| { | ||
| var order = await orderRepository.GetByIdAsync(first.OrderId); | ||
| if (order == null || order.Deleted || order.OrderStatusId == (int)OrderStatusSystem.Cancelled) |
Comment on lines
+66
to
+67
| var orderItem = order.OrderItems.FirstOrDefault(x => x.Id == first.OrderItemId) ?? | ||
| order.OrderItems.FirstOrDefault(x => x.ProductId == first.ProductId); |
Comment on lines
+109
to
+111
| return productReservationRepository.UpdateManyAsync( | ||
| x => x.OrderId == first.OrderId && x.OrderItemId == first.OrderItemId && x.ProductId == first.ProductId, | ||
| UpdateBuilder<ProductReservation>.Create().Set(x => x.ReminderSentOnUtc, utcNow)); |
| Resource = WebUtility.HtmlEncode(request.Reservation.Resource ?? ""), | ||
| Parameter = WebUtility.HtmlEncode(request.Reservation.Parameter ?? ""), | ||
| Duration = WebUtility.HtmlEncode(request.Reservation.Duration ?? ""), | ||
| Url = $"{url}/account/reservations" |
- Cap the reminder hours at 720, in the service and in a settings validator - Leave an order awaiting approval, or not saved yet, for a later run - Mark the slots before the e-mail is queued, clear the mark when queuing fails - Match slots kept without their order item to the item booking their date - Link the reservations page only for a registered customer, when it is shown - Format the dates in the culture of the e-mail's language - List the Reservation tokens in the template editor
| private static (OrderItem, ProductReservation) HourSlot() | ||
| { | ||
| var orderItem = new OrderItem { RentalStartDateUtc = new DateTime(2026, 12, 15, 9, 0, 0, DateTimeKind.Utc) }; | ||
| return (orderItem, new ProductReservation { Date = orderItem.RentalStartDateUtc.Value }); |
Comment on lines
+87
to
+90
| catch (Exception ex) | ||
| { | ||
| logger.LogError(ex, "Reservation reminder for order {OrderId} failed", first.OrderId); | ||
| } |
added 3 commits
December 2, 2026 13:47
The validation filter validates an action's model, not the models inside it, so a validator of the shopping cart part never ran.
The order, shopping cart and loyalty points settings validators each validate a part of the posted sales settings; the validation filter validates only the action's model, so none of them ran. The sales settings validator now runs each one on its part.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Type: feature
Issue
A customer who booked a reservation hears nothing more from the store until the day comes. There is no reminder before the reserved date.
Solution
ReservationReminderScheduleTask→IReservationReminderService), every 60 minutes, enabled for new installs and by the upgrade.ShoppingCartSettings.ReservationReminderHoursBefore(default 24, 0 = no reminders, at most 720 —MaxReservationReminderHoursBefore, checked by a newShoppingCartSettingsValidatorand capped in the service), next to the reservation hold in the shopping cart settings of Admin and Store.ProductReservation.Dateindex; no new index), groups them by order item and applies each store's own window to the order. One e-mail per order item: a day range is reminded once, by its first day. Slots booked before Hold reservation slots in the cart on the slot itself #1158 carry no order item: each goes to the order's item of its product that books its date.ProductReservation.ReminderSentOnUtc), so the later days of a range never trigger a second e-mail. The stamp is set before the e-mail is queued and cleared when queuing fails, so a failed write never mails the customer every hour. Stamped also, without an e-mail: a reservation ordered when its reminder was due already (the order e-mail has just told the customer), one already begun, a cancelled or deleted order, a product that is gone. Left for a later run, unstamped: an order awaiting approval (reminded once approved, while still in time) and an order not saved yet (a checkout books the slots before it saves the order). An inactive template queues nothing and still stamps, as the payment reminders do.TryBookclears the stamp: a slot freed by a cancelled order and booked again gets its own reminder.ReservationReminder.CustomerNotification(IOrderMessageProviderService.SendReservationReminderCustomerMessage): order tokens plus a new{{Reservation.*}}drop —ProductName,Date(store time,ReservationDateFormat, "from - to" for a range, as the order and the account page show it, in the culture of the e-mail's language — the task has none of its own),Resource,Parameter,Duration,Url(the customer's reservations page from List the customer's reservations in the account #1168; empty for a guest or whenHideReservationsTabis on, and the template then shows no button). The tokens are listed in the template editor. An order note "Reservation reminder e-mail sent" when it was queued.MigrationReservationReminders(2.5): the task (enabled) and the template; idempotent. The installer seeds the same; a test keeps the two template bodies equal.DefaultLanguage.xmlandUpgrade/en_250.xml.OrderSettingsValidator— payment reminder days 0–365, gift vouchers not activated on Pending;LoyaltyPointsSettingsValidator— points not awarded on Pending). The validation filter validates an action's model, not the models inside it. NewSalesSettingsValidatorruns each part's validator on its part, in Admin and Store.Breaking changes
None. Note: after the upgrade, stores start reminding the customers of reservations beginning in the next 24 hours (decided for this feature); set the hours to 0 or disable the template to opt out.
Testing
Unit tests:
ReservationReminderServiceTests(window, one e-mail per item of a day range, no double send, past and vacant slots, cancelled order, ordered within the window, range already begun, reminders off, per-store windows, inactive template, failed send retried, slot without order item, two items of a product without order item, order not saved yet, awaiting approval, hours above the limit),GetReservationTokensCommandHandlerTests(guest, hidden page, language culture),ShoppingCartSettingsValidatorTests,SalesSettingsValidatorTests,ReservationReminderScheduleTaskTests,MigrationReservationRemindersTests,ProductReservationServiceTests(rebooked slot), seed and mapping tests. Every test project passes on its own; full-solution runs fail a varying few tests in other projects (the known parallel-run flakiness), each of which passes alone.E2E (before the review fixes; clone of the shared reservations DB, stamped 2.4 so the migration runs):
customer@yourstore.combook a Climbing Wall Session slot for today and Trailforge Camping Tent Rental for tomorrow–the day after, check out with Cash on delivery./account/reservations.E2E after the review fixes (same recipe, a fresh clone, admin window set to 48 h):
Start: the migration adds the task and the template; the template's button sits inside
{% if Reservation.Url != '' %}.Admin → message template editor lists
{{Reservation.ProductName}}…{{Reservation.Url}}.Admin → Settings → Sales: 48 saved; 1000 rejected with "Enter from 0 to 720 hours." and 48 kept. Store panel: 1000 rejected the same way.
Four orders of tomorrow's climbing slots:
customer@(English),customer2@after switching the store to a new Polish (pl-PL) language, a guest, and a secondcustomer@order set to Awaiting approval; orders moved three days back.Run now: three e-mails — English
12/3/2026 1:00:00 PMwith the reservations link, Polish3.12.2026 13:00:00with the link, the guest's without the button; the order awaiting approval neither mailed nor stamped.Order set to Pending (as an approval does; the panel does not let an admin take an order out of Awaiting approval) → Run now: its reminder is sent, no other e-mail repeats.
Sales settings validators (fresh clone): Admin rejects payment reminder 400 days, reminder hours 1000, loyalty points awarded on Pending and gift vouchers activated on Pending, nothing saved; a valid save (5 days, 12 h) is kept. Store panel rejects 1000 hours and 400 days, saves 6 h.