# Venue extras adapter

`useVenueExtras` owns ordinary retail extras for one booking entry. `usePartyExtras` remains a compatible alias, defaulting to Party mode. The adapter does not create bookings or stage/replace the entire retail selection.

**Latest decision, 2026-10-27: both modes display prices and query quotations using the current venue-local time. Extras pricing does not follow a Party or ticket's booking date/time. This supersedes the earlier Party service-time rule. Material and OS code are implemented and locally validated on port 8017; not yet committed or released.**

**2026-10-29 request contract:** the page supplies its single OS `createVenueCatalogSession` handle as `catalogSession`. The catalog loads once for the pool. Only an explicit card selection through `prepare` may call `prepareProductDetail`: OS may fetch missing top-level variant detail once for `is_variant === 1`, then caches that result across the booking flow and pools. Non-variant products never require this detail GET. Configuration confirmation, quantity changes and final revalidation use pure local queries/quotes; they never initiate first-time detail hydration or ordinary HTTP fallback. The order backend remains authoritative at submission.

The following table describes the pricing contract:

| Mode | Owner | Pricing timestamp | Row role |
| --- | --- | --- | --- |
| `party` (default) | Current main product UID and entry scope | Current venue-local time for display and quotation; fresh current timestamp on add, quantity change and final revalidation | `party_extra` |
| `tickets` | Current new order and entry scope; requires at least one saved ticket in that scope | A fresh venue-local purchase timestamp on each add, quantity change and final revalidation | `tickets_extra` |

Both modes supply the authoritative `timeZone`; Party also supplies its real `parentLineUid`. Tickets uses `mode: 'tickets'` without a fake parent UID. `currentVenueDatetime` is shared by the independent catalog and SDK customer repricing; the controller's `venuePurchaseDatetime` wrapper preserves its error contract. Each request/action captures current venue time once; a later add, quantity change or revalidation captures a fresh value. Extras with an enabled product or selected variant Holder policy select profiles inside their own retail detail. They keep order-detail Holder relations and do not add a booking. Booking rescheduling does not select a future quotation for extras.

`venue_booking_service_datetime` remains the persisted key for compatibility: on an extra it now means purchase quote time, while on a main line it still means booking start time. OS add/replacement validates a legitimate extra timestamp without requiring equality with the parent. Deploy the corresponding OS change with this material.

- Supply the extras step's explicit `productLoadParams.menu_list_ids`, `scopeKey`, customer, independent catalog and OS/SDK cart. Both modes require `timeZone`; Party additionally supplies `parentLineUid`. Caller-supplied `serviceDatetime` or catalog schedule fields cannot override current-time pricing. Stable context identity excludes quote seconds and booking dates but retains timezone, owner, menu, customer and scope. Either template may omit `steps.extras`; when supplied, it must have its own nonempty menu IDs.
- Supply the same `catalogSession` used by the extras list. Its `queryCatalogProductDetail` evaluates cached pool data at the current venue time, and its `calculateProductBookingPrice` uses OS local pricing without network fallback. Missing session, incomplete product relations or unavailable rules fail closed; a partial list DTO is not a substitute. Supply `resolveSelectionPolicy` from the active resolved sales settings; required-option and over-sold rules are shared with the SKU shell and resolved again before pricing/revalidation.
- Call `prepare(product, quantity)` only for an explicit user selection to open configuration. It invokes `prepareProductDetail({ ...params, retry: true })`; a repeated explicit open can retry a failed variant hydration, while a successful cached hydration is reused. It returns `ready` with a product-configuration `plan`, `configuration` and opaque `session` for the configuration shell. `direct` has neither selectable SKU groups nor an active Holder policy and can call `commit(session, configuration)` immediately. `invalid` has displayable `issues`. The internal preparation used by `setProductQuantity` stays local and does not call this hydration API.
- Venue extras render `ready` in `VenueExtraDetailModal`, reusing Kiosk's `CompensatedPisellContainer`, immersive detail view and original `SKUOptionsSelection`. It uses local pricing, displays required or optional Holder profiles after SKU selection when configured, and writes `commit(session, configuration, quantity, holderRelations)`. Edits reopen a physical cart line by UID and preserve its SKU and allergy declaration while editing the quantity and profiles. Main Party configuration keeps its existing shell.
- `commit` locally reevaluates scoped detail, normalizes selection IDs against that detail, refreshes option prices, asks the OS catalog session for the selected variant's price at the mode's pricing timestamp without a booking/duration payload, merges bundle quotation prices, and calls `addRetailProduct` with the supplied configured product. Later clicks capture a fresh venue timestamp while reusing the same pool; neither final revalidation nor Party replacement preparation fetches another product list/detail.
- Before that write, `cart.prepareAllergyBeforeCommit` opens the existing allergy gate when required. Its note draft is sent in the same guarded `addRetailProduct` call. `cancelled` means no cart write; a configuration modal should return false from confirmation and stay available.
- The returned `quantityByProductId` only counts the selected mode's rows: Party children of the current parent, or Tickets extras in the current scope. `setProductQuantity` can return `choose-line` when decrementing several rows; render those rows and call `setLineQuantity(lineUid, quantity)` after an explicit choice. Repeated + on a plain, single existing row updates that row.
- Menu/customer/timezone/owner changes require review; a changed booking timestamp alone does not expire a retail selection. Saving a Party main change and final submission still revalidate at current venue time. `prepareRevalidation(nextContext?)` is read-only preparation. For Party, its `validRows` are configured **retail source products**, with old extra UID in metadata, ready for `relatedRetailProducts` on the OS's atomic main-and-extras replacement. Do not commit the main replacement if `invalidItems` is nonempty. Invalid rows remain available for repair/removal.
- `revalidate()` applies repricing only to the current context; call it at the final submission boundary for both modes and block submission when it returns invalid items. When `priceChanged` is true, show the updated total and require a further confirmation. A timestamp-only update does not set `priceChanged`. Never use it to write extras before a main-product replacement succeeds.
- Unchanged pre-discount prices/configuration/quantity and quote associations produce no update or summary recalculation. A changed quote shelf with unchanged money refreshes only the quote identity and preserves discounts. Actual price changes use the existing reprice conversion and are visible to the owner's final amount confirmation.
- Quantity changes and current-context repricing use OS `updateOrderProducts(updates, { beforeApply, isCurrentOrder })`. The write guard checks the captured extras snapshot; the ownership guard checks order, customer, parent and context both before and after publication. Supply this guarded OS capability; a preflight-only SDK update cannot protect an asynchronous write.
- The direct retail OS write preserves flat role/scope/pricing metadata (plus real parent UID for Party) and disables implicit merging. Tickets requires the OS `tickets_extra` guarded branch, which rechecks same order/customer, scope and saved ticket presence at publication. Adding a new extra never reuses an old line UID. Atomic replacement alone carries the existing UID through metadata.
- `detailMissingGroupPolicy` defaults to `reject`; use `absent-means-none` only when the detail endpoint guarantees omitted groups mean none. Positive group counts without group data still fail closed. A weighing product requires a separate weight workflow and is reported as unsupported here.

All callbacks that change the cart are asynchronous. Disable the corresponding controls while `busy`; display invalid/choose-line results rather than treating every resolved promise as success. The adapter rejects stale sessions, replacement catalog-session handles, stale catalog results, and changes to the parent/context before a write. Replacing the session invalidates an open configuration even when its products array is unchanged. Removing an existing line remains available without a catalog session.

The owner supplies `beforeMutate` to await the existing business availability gate. The adapter rechecks ownership after that await and again inside the OS write. Session identity includes the actual order object and draft identity, so reopening/resetting an order cannot reuse an old extra selection.

For Tickets, `getVenueExtraRows(products, { mode: 'tickets', scopeKey })` returns order-level extras without a parent. Delete the final ticket and these exact extra UIDs together through the guarded batch remove API. An extra is never evidence that a booking exists and must not appear in Holder/resource-form tasks. `readVenueOrderBindings` separates extras from booking bindings and validates role/scope, quantity and absence of booking linkage. Session persistence can continue serializing the complete temporary order; do not reconstruct extra ownership from a ticket UID.

Tickets writes require the explicit synchronous OS capability `supportsVenueTicketExtras() === true`. Missing/false support raises `TICKETS_EXTRAS_SERVICE_UPGRADE_REQUIRED` before quoting or consuming the open session; the old generic retail merge path is never used as a fallback. Party and removal of an existing invalid extra remain usable.
