Orchardcore bookings

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore bookings is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for the CrestApps Orchard Core Bookings commerce module. Covers the BookingPart for Departure, Nightly and TimeSlot products, capacity per date in BookingSlot records, occupancy and weekend pricing, deposits with the balance charged to the saved card, cancellation tiers and refunds, request-to

How to use this skill

Skill file

Orchard Core Bookings - Prompt Templates

Sell Products by Date

You are an Orchard Core expert. Generate accurate setup, recipes and extension guidance for the CrestApps Bookings module, which sells products by date as fixed departures, nightly stays or time slots.

Guidelines

Feature and Services

| Item | Value |

|---|---|

| Feature ID | CrestApps.OrchardCore.Bookings |

| Content part | BookingPart |

| YesSql collection | Bookings (BookingSlot, Booking, BookingBalance; each index declared .ExclusiveToDocumentType().SingleRecordPerDocument()) |

| Stores | IBookingSlotStore, IBookingStore, IBookingBalanceStore |

| Services | BookingSchedule, BookingCapacityService, BookingService, BookingDepositService, BookingBalanceCharger |

| Commerce seams filled | ICartLineHandler, IOrderEventHandler, ICheckoutTenderProvider, ICartActionProvider, two CheckoutFlow display drivers; ITransactionPaymentHandler (balance payments), TransactionEventHandlerBase (scheduled charge declined or abandoned) |

| Seams offered | IBookingHandler, IBookingSlotFilter, IBookingPaymentHandler |

| Balance tender key | booking-balance |

| Traveler content type | Traveler |

| Permission | ManageBookings (Administrator, Store manager, Customer support) |

| Recipe step | BookingDates (needs OrchardCore.Recipes.Core) |

| Deployment step | Booking dates (BookingDatesDeploymentStep, category Commerce) |

| Workflow events | Ten booking and payment events in the Commerce category (with OrchardCore.Workflows) |

| Report Builder | Bookings data source (with OrchardCore.DataPipelines.Core) |

| Calendar type | Bookings (event type Booking), with Calendars on |

| Sample recipe | BookingsSample (a tour, an appointment and a room) |

Enable the Feature

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "CrestApps.OrchardCore.Products",
        "CrestApps.OrchardCore.Carts",
        "CrestApps.OrchardCore.Orders",
        "CrestApps.OrchardCore.Customers",
        "CrestApps.OrchardCore.Checkout",
        "CrestApps.OrchardCore.Bookings"
      ],
      "disable": []
    }
  ]
}

Booking Kinds and the Part

BookingKind is Departure (0), Nightly (1) or TimeSlot (2). Defaults: Capacity 10, MinNights 1, MaxNights 28, SlotMinutes 60, DaysAhead 180, BalanceDueDaysBefore 30.

| Property | Meaning |

|---|---|

| Kind | Departure (fixed dates the store adds), Nightly (check-in to check-out), TimeSlot (times inside opening hours) |

| Capacity | Seats per departure, units per night, or bookings per time slot. A departure date can override it |

| PricePerPerson | Price is per person (a tour) rather than per unit (a room) |

| Occupancies | BookingOccupancy (Id, Label, People, PriceAdjustment), such as a double room or a single supplement |

| MinNights, MaxNights, WeekendPrice | Stay length, and the price of a Friday or Saturday night |

| Hours, SlotMinutes | BookingOpeningHours per day of week (Day, Opens, Closes) and the slot length |

| DaysAhead | How far ahead stays and slots can be booked |

| DepositPercent, BalanceDueDaysBefore | Share paid now, and when the rest is due |

| CancellationTiers | BookingCancellationTier (DaysBefore, FeePercent) |

| RequestToBook | The store confirms each booking before it is paid |

| AskForTravelers | Checkout asks each person's details from the Traveler content type |

| BlockingCalendarId | With Calendars on, Block with calendar: dates or times busy on that calendar can't be booked |

Example content item part data, as in the sample recipe:

{
  "steps": [
    {
      "name": "Content",
      "data": [
        {
          "ContentItemId": "4bkngtour0alpinelakes0000a",
          "ContentType": "Tour",
          "DisplayText": "Alpine Lakes Tour",
          "Latest": true,
          "Published": true,
          "TitlePart": { "Title": "Alpine Lakes Tour" },
          "ProductPart": { "Price": 1000, "Currency": "USD", "Sku": "TOUR-ALPINE", "IsPurchasable": true },
          "BookingPart": {
            "Kind": 0,
            "Capacity": 12,
            "PricePerPerson": true,
            "Occupancies": [
              { "Id": "4bkngocc0double000000000000", "Label": "Double room", "People": 2, "PriceAdjustment": 0 },
              { "Id": "4bkngocc0single000000000000", "Label": "Single room", "People": 1, "PriceAdjustment": 300 }
            ],
            "DepositPercent": 15,
            "BalanceDueDaysBefore": 45,
            "CancellationTiers": [
              { "DaysBefore": 60, "FeePercent": 10 },
              { "DaysBefore": 30, "FeePercent": 50 }
            ],
            "RequestToBook": false,
            "AskForTravelers": true
          }
        }
      ]
    }
  ]
}

BookingPart is added to CartOptions.ChooseOnProductPageParts, so product cards link to the product page. The BookingPicker shape renders in the ProductAction display type and posts with the Add to cart form as details[booking.date], details[booking.end] and details[booking.occupancy] (constants in BookingsConstants.Details). The query strings ?date= and ?end= preselect them.

Dates and Capacity

BookingSlot is one date of a product: SlotKey, StartsUtc, Capacity, Held, Sold, an optional Price in the product's currency, and Closed.

Add Dates with a Recipe

Each date names the product by ContentItemId and gives Date (yyyy-MM-dd) or DaysFromToday, plus optional Time (HH:mm), Capacity (default 10) and Price. A date the product already has is left unchanged, so the step is safe to rerun. Place it after the Content step that creates the products. The Booking dates deployment step (BookingDatesDeploymentStep, category Commerce) exports upcoming open dates in this shape; past and closed dates and what is held or sold stay on the site.

{
  "steps": [
    {
      "name": "BookingDates",
      "Dates": [
        { "ContentItemId": "4bkngtour0alpinelakes0000a", "Date": "2027-06-14", "Capacity": 12 },
        { "ContentItemId": "4bkngtour0alpinelakes0000a", "DaysFromToday": 110, "Capacity": 12, "Price": 1150 }
      ]
    }
  ]
}

Cart, Orders and Booking Status

Deposits and the Balance

Cancellation and Requests to Book

Travelers

Create a Traveler content type with the fields to collect (for example a required FullName text field). BookingTravelersCheckoutFlowDisplayDriver adds one editor per person to the Contact step for parts with AskForTravelers, and stores the content on Booking.Travelers.

Booking Hooks

| Seam | Called | Use it to |

|---|---|---|

| IBookingHandler | By BookingStore inside the save: SavingAsync(BookingSavingContext) and DeletingAsync(Booking) | Follow status changes and moves; what it writes commits with the booking. Use a ShellScope deferred task for after-commit work. |

| IBookingSlotFilter | By BookingCapacityService (remaining and hold) | Close dates or times for reasons Bookings doesn't track (GetClosedSlotKeysAsync(contentItemId, part, slotKeys, timeZone) returns the closed keys) |

| IBookingPaymentHandler | When money moves: PaymentReceivedAsync, PaymentFailedAsync, RefundedAsync | Follow full payments, deposits, balance payments, failed balance charges and refunds |

BookingSavingContext has Booking, IsNew, PreviousStatus, PreviousStartsUtc, PreviousEndsUtc, and the computed StatusChanged and Rescheduled (the snapshot is a BookingChangeMarker kept in the booking's properties; bookings saved before the hooks existed have null previous values on their first save). BookingPaymentContext has Bookings (only confirmed ones for a balance payment, a failure or a refund), OrderId, OrderNumber, PaymentKind (FullPayment, Deposit, Balance; null for a refund), Amount and Currency (for the whole order), Reason, IsFinal and Reference. Each payment, declined try and refund is reported once.

public sealed class CanceledBookingHandler : IBookingHandler
{
    private readonly ILogger _logger;

    public CanceledBookingHandler(ILogger<CanceledBookingHandler> logger)
    {
        _logger = logger;
    }

    public Task SavingAsync(BookingSavingContext context, CancellationToken cancellationToken = default)
    {
        if (context.StatusChanged && context.Booking.Status == BookingStatus.Canceled)
        {
            _logger.LogInformation("Booking {BookingId} was canceled.", context.Booking.ItemId);
        }

        return Task.CompletedTask;
    }

    public Task DeletingAsync(Booking booking, CancellationToken cancellationToken = default)
        => Task.CompletedTask;
}

// Startup: services.AddScoped<IBookingHandler, CanceledBookingHandler>();
public sealed class ClosedOnTuesdaysSlotFilter : IBookingSlotFilter
{
    public Task<IReadOnlyCollection<string>> GetClosedSlotKeysAsync(string contentItemId, BookingPart part, IReadOnlyList<string> slotKeys, TimeZoneInfo timeZone, CancellationToken cancellationToken = default)
    {
        // Slot keys are yyyy-MM-dd or yyyy-MM-ddTHH:mm in the given time zone.
        IReadOnlyCollection<string> closed = slotKeys
            .Where(key => DateTime.ParseExact(key[..10], "yyyy-MM-dd", CultureInfo.InvariantCulture).DayOfWeek == DayOfWeek.Tuesday)
            .ToList();

        return Task.FromResult(closed);
    }
}

// Startup: services.AddScoped<IBookingSlotFilter, ClosedOnTuesdaysSlotFilter>();

The store resolves handlers on first use, so a handler may depend on services that depend on the store. A payment handler that throws is logged and never undoes the payment.

Workflow Events

With OrchardCore.Workflows on, these events are in the Commerce category, correlated by booking id, and triggered in a deferred task after the session commits. Booking events come from BookingWorkflowHandler (an IBookingHandler; one save can raise several, such as Created and Confirmed); payment events come from BookingPaymentWorkflowHandler, once for each booking the money is for.

| Activity | Display name | Raised when |

|---|---|---|

| BookingCreatedEvent | Booking Created | A booking is made (held, requested or confirmed) |

| BookingConfirmedEvent | Booking Confirmed | It becomes Confirmed, such as when the order is paid |

| BookingRescheduledEvent | Booking Rescheduled | It moves to other dates |

| BookingCanceledEvent | Booking Canceled | It becomes Canceled |

| BookingCompletedEvent | Booking Completed | It is marked complete |

| BookingNoShowEvent | Booking No-Show | It is marked a no-show |

| BookingExpiredEvent | Booking Expired | A hold or request runs out |

| BookingPaymentReceivedEvent | Booking Payment Received | Paid in full or by deposit, or a payment is applied to a balance |

| BookingPaymentFailedEvent | Booking Payment Failed | Charging the balance to the kept card fails |

| BookingRefundedEvent | Booking Refunded | A refund is recorded on an order with confirmed bookings |

Input: Booking, BookingId, OrderId, OrderNumber, ContentItemId, Title, StartsUtc, EndsUtc, Status, PreviousStatus, CustomerName, CustomerEmail. Payment events add Amount and Currency (for the whole order, so an order with two bookings raises the event twice with the same amount), PaymentKind, Reason, IsFinal and PaymentReference.

Bookings on the Calendar

Whenever Bookings and CrestApps.OrchardCore.Calendars are both on:

Report Builder Data Source

With OrchardCore.DataPipelines.Core on, the Bookings data source (Bookings) has the data sets Bookings (one row per booking, default date when booked), BookingSlots (one row per product date) and BookingBalances (one row per balance owed after a deposit). They need ManageBookings. Travelers' details, cancel reasons, cancellation policies, cards and payment provider errors are never exposed. See orchardcore-report-builder.

Storefront and Admin

| Surface | Route or menu |

|---|---|

| Booking search (BookingSearch) | GET bookings, finds availability for people between two dates |

| Request to book (BookingRequest) | bookings/request |

| Bookings admin | Commerce > Bookings (bookings, bookings/{action}/{itemId?}), with a booking detail, dates per product, and a Calendar (ManageBookings) |

| Sync to calendar | bookings-calendar/sync (admin, with Calendars on) |

Troubleshooting

| Symptom | Check |

|---|---|

| Product card has no Add to cart | Expected. Booking products are chosen on the product page |

| A departure date cannot be booked | Add the date with the admin Dates page or the BookingDates step |

| Order refused at checkout | The dates are gone, or a RequestToBook product was checked out without a quote |

| Balance never charged | The deposit must be paid with a provider that saves cards; the Transactions saved card charge service runs the scheduled charge, and BookingsBackgroundTask must run (tenant has served a request) to hand older balances to it |

| Balance Failed after three tries | The card was declined on the due date and the two daily retries, or the bank asked the buyer to approve it; the buyer pays from the invoice's pay link, or staff use Charge the card now |

| BookingDates step not found | Enable OrchardCore.Recipes.Core and place the step inside { "steps": [...] } |

| Traveler editors missing | The Traveler type needs fields, and the part needs AskForTravelers |

| Bookings missing from the calendar | Calendars must be on; run Sync to calendar for bookings made before it was enabled |

| Bookings calendar not visible | It is private; share it, or use ViewAllCalendars |

| Dates show as full with places left | An IBookingSlotFilter closed them, such as Block with calendar finding busy time that day |

| No booking workflow event | OrchardCore.Workflows must be on; events fire after the session commits |

Related skills: orchardcore-products, orchardcore-checkout, orchardcore-payments, orchardcore-transactions, orchardcore-orders, orchardcore-calendars, orchardcore-scheduling, orchardcore-report-builder.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.