Skip to content

Add reservation products to an existing order in the admin - #1176

Merged
grandnode-dev merged 2 commits into
developfrom
feature/reservation-add-to-order
Dec 3, 2026
Merged

grandnode-dev merged 2 commits into
developfrom
feature/reservation-add-to-order

Conversation

@grandnode-dev

Copy link
Copy Markdown
Member

Type: feature

Issue

Adding a reservation product to an existing order in the admin was not possible: the add-product popup showed a hard-coded "Reservation products are not currently supported for adding to an existing order". Staff who take a booking by phone had no way to put it on the customer's order.

Solution

  • The add-product popup (Admin and Store panels; the Vendor panel cannot edit orders) now takes a reservation product:
    • by minutes or hours: a date, then one of its free slots (time · parameter · duration);
    • by days: a start date and an end date; picking the start sets the end dates a range can take on one resource, and says when no range can start on that date.
  • The free slots come from the availability the storefront reads (IProductReservationService.GetAvailability, R12), for the order's customer, through a new Order/ReservationAvailability GET action (Edit permission, order and product scoped as the other add-product actions).
  • On Add, the item is checked by the cart's reservation validator without a hold (the product's booking rules, R17, apply as on the storefront), then the slots are booked with TryBook (R2/R6, under the product lock) for the new order item before the item is added. When another cart or order took them meanwhile, the popup shows the warning and nothing is added.
  • The order item gets the rental dates and the same reservation text the checkout writes: PlaceOrderCommandHandler.ReservationInfo moved to ProductReservationExtensions.FormatReservationInfo.
  • Price: the price fields are a day's price for a product by days (as the product's price is); the item costs it once per day booked. The day count is shared with PricingService (ProductReservationExtensions.RentalDays). Quantity is 1 for a reservation, as in the cart.
  • The existing "A new order item has been added" order note covers the edit; no second note.
  • 7 new Admin resources in DefaultLanguage.xml and Upgrade/en_250.xml.

Breaking changes

OrderProductViewModelService takes two more constructor dependencies (IProductReservationService, ISettingService); IOrderProductViewModelService has a new method GetReservationAvailability.

Testing

  1. Place an order as a customer (any product).
  2. Admin → the order → Products → Add product → pick an hour reservation product (e.g. Climbing Wall Session). Choose a date: the slot list shows the free slots in store time. Pick one → Add product. The order shows the item with the date, parameter and duration; the slot is booked for that order item in the product's Calendar tab.
  3. Open the popup again for the same date: the booked slot is not offered. Pick another slot, then (before adding) put that slot in another customer's cart on the storefront. Add product → "Already reserved", nothing added.
  4. Add a day product (e.g. the tent) with a range across a day only one resource has: picking the start limits the end date; the item is priced per day × days and its days are booked on one resource.
  5. Repeat step 2 in the Store panel as a store manager.

Unit tests: OrderProductViewModelServiceTests (free slot booked for the new item, slot taken meanwhile, validator warning books nothing, day range priced per day with store dates), ProductReservationExtensionsTests (RentalDays across a clock change, FormatReservationInfo). Full dotnet test GrandNode.slnx green.

E2E on a clone of the shared reservations DB: steps 2–5 above (climbing wall 09:00 slot booked for the new item; 10:00 slot held by customer2 meanwhile → warning, no item; tent 12–15 Jan across a Wednesday booked on Tent 1 at 3 × day price; 24 Dec start → "no reservation can start"; Store panel popup and availability).

Staff pick a slot of an hour product or a date range of a day product in the add-product popup. The free slots come from the same availability the storefront reads, for the order's customer, and the product's booking rules apply. The slots are booked for the new order item before it is added; when another order took them meanwhile, the popup says so and nothing is added. A range by days is priced per day, the order item gets the rental dates and the reservation text the checkout writes.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 09:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

public class OrderProductViewModelServiceTests
{
private Mock<IMediator> _mediator;
private Mock<IProductReservationService> _productReservationService;
{
private Mock<IMediator> _mediator;
private Mock<IProductReservationService> _productReservationService;
private Mock<IShoppingCartValidator> _validator;
- Free the reserved slots when inserting the order item fails before the
  order is saved with it.
- Refuse adding a product to a canceled order and hide Add new there.
- Show the posted reservation again with the warnings it got.
- Show a message when the free time cannot be read in the popup.

var model = (result as ViewResult)?.Model as OrderModel.AddOrderProductModel.ProductDetailsModel;
Assert.IsNotNull(model);
CollectionAssert.AreEqual(new[] { "MinimumDays" }, model.Warnings);
public class OrderProductViewModelServiceTests
{
private Mock<IMediator> _mediator;
private Mock<IOrderService> _orderService;
@grandnode-dev
grandnode-dev merged commit ea63ebd into develop Dec 3, 2026
9 checks passed
@grandnode-dev
grandnode-dev deleted the feature/reservation-add-to-order branch December 3, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants