Developer portal

Embedded Seating Plans V2

How to use our new seating plan for reserved and General Admission tickets

Seat Plan V2 lets API clients use our new seating plan, the same one used on our website, for ticket selection in the middle of a booking made through our API. It supports mixed seating performances, where one plan has both reserved seats and General Admission (GA) areas:

  • Reserved seats are selected one by one on the plan.
  • GA areas are drawn as a single shape. The customer clicks the area and chooses how many tickets they want.

The seating plan only handles ticket selection. It never adds tickets to a basket. When the customer confirms their selection, the seating plan gives your page the selected reserved ticket IDs and GA quantities, and your server adds them to the basket with Add Tickets to Basket (v3).

Seat Plan V2 is not a new version of the Embedded Seating Plans script. It is a separate script with its own initialisation. If you already use LTD.SeatPlan.init(), see Migrating from V1.

Components

Seat plan container

Seat Plan wrapper element. The whole seat plan is generated inside this element: the plan, zoom controls, tooltips and messages.

<div id="ltd-seatplan-v2" style="height: 600px"></div>

The element must have a height. The plan fills its container and does not size itself.

Your page must not add or change anything inside this element after the seat plan has been created.

Filter panel (optional)

Filters seats by price band. Turned off by default. When turned on, it is rendered inside the seat plan container, or in your own element. See filterPanel in Configuration properties.

<div id="ltd-seatplan-v2-filter"></div>

Basket panel (optional)

Shows the selected tickets, the total price and a Reserve button that updates itself. When the customer presses Reserve, the seating plan validates the selection and then calls your onSubmitRequested handler. Turned off by default. When turned on, it is rendered inside the seat plan container, or in your own element with the sidebar layout. Leave it off if you show the selection in your own basket and call submitSelection() from your own button. See basketPanel in Configuration properties.

<div id="ltd-seatplan-v2-basket"></div>

Initialisation

Place the stylesheet in the head section:

<link rel="stylesheet" href="https://seatplan-prod-bahjatbefnc9h6a7.a01.azurefd.net/seatplan.css" />

To initialise the Seat Plan, place the following code anywhere below the Seat Plan component(s). We recommend the bottom of the document's body section.

<script src="https://seatplan-prod-bahjatbefnc9h6a7.a01.azurefd.net/seatplan.iife.js"></script>
<script>
    (function (Seatplan) {
        var seatPlan = Seatplan.createSeatPlanWithConfig(
            document.getElementById('ltd-seatplan-v2'),
            {
                request: {
                    performanceId: 'performance-id',
                    clientId: 'your-client-id',
                },
                httpConfig: {
                    baseUrl: 'https://spdp.londontheatredirect.com',
                    availabilityQueryMode: 'legacy',
                },
                onSubmitRequested: function (payload) {
                    // Send payload.ticketIds and payload.generalAdmission to your server
                },
            }
        );
    }(window.Seatplan));
</script>

The script creates one global object, window.Seatplan. createSeatPlanWithConfig(container, options) draws the seating plan in container and returns a seat plan instance.

To show a different performance, call destroy() on the current instance and create a new one.

Initialisation properties

Name Type Description Required Default value
request RequestConfigObject Which performance to show, and for whom true
httpConfig HttpConfigObject Where the seating plan loads its data from true
config SeatPlanConfigObject Look and behaviour of the seating plan false
onSubmitRequested function Called when the customer presses Reserve and the selection is valid. See Booking the selected tickets false
onSelectionChanged function Called every time the selection changes false
onError function Called when an error occurs false
onPriceBandsChanged function Called when availability is loaded or refreshed, with the price bands to show in your own legend false
priceBandPalette string[] Colours used for price bands, in order false
RequestConfigObject
Name Type Description Required Default value
performanceId string ID of the desired performance true
clientId string Your client ID (please contact your Sales manager) true
locale string Valid IETF language tag. en-GB and fr-FR are translated; other values use English false en-GB
basketId string ID of the customer's current basket, from Create Basket. Lets the seating plan show tickets already in the basket false
HttpConfigObject
Name Type Description Required Default value
baseUrl string Seating plan data host. Use https://spdp.londontheatredirect.com true
availabilityQueryMode string Use legacy false modern
timeoutMs number Request timeout in milliseconds false 10000

The endpoint paths have working defaults and should not be changed.

Configuration properties

Passed as config. All properties are optional.

Name Type Description Default value
limitSelectedSeats number Limits the number of tickets that can be selected at once. Each GA ticket counts as one. 0 means no limit 0
margin number Space around the whole seating plan, in pixels 0
canvasFillMethod string contain fits the whole plan in the container when it loads. cover fills the container contain
basketPanel boolean or BasketPanelConfigObject Shows the basket panel with the Reserve button false
filterPanel boolean or FilterPanelConfigObject Shows the price band filter false
showLegend boolean Shows the price band legend true
showOffers boolean Shows offer stars on seats true
displayFacePrice boolean Shows the face value in seat tooltips false
disableStrikethroughPrice boolean Hides strikethrough prices for discounted or offer seats false
hideGARemainingTickets boolean Hides the number of tickets left in GA areas
doubleTapZoom boolean Zooms in on double tap true
scrollMove boolean Uses the scroll wheel to move the seating plan instead of zooming false
showZoomControls boolean Shows the zoom buttons true
showFullscreenControl boolean Shows the full screen button false
availabilityPolling boolean Refreshes availability in the background while the customer is choosing true
keepSelectionOnValidationFailure boolean Keeps the selection when validation fails, instead of removing the invalid seat false
formatPrice function Price formatter. Here you can completely redefine how prices are displayed. (price?: number, band?: string): string
strings SeatPlanStringOverridesObject Replaces any text shown by the seating plan
enableLegacyEvents boolean Also fires the V1 LTD.SeatPlan.* and LTD.Basket.* DOM events. See Migrating from V1 false
BasketPanelConfigObject
Name Type Description Default value
enabled boolean Shows the basket panel true when an object is passed
container HTMLElement or string Element, or CSS selector, to render the basket panel into. Used only with the sidebar layout inside the seat plan container
layout string inline (inside the seat plan container) or sidebar (in container) inline
showClearAll boolean Shows a "Clear all" button true
hideIncludingAllFees boolean Hides the "Includes all fees." text below the total price false
FilterPanelConfigObject
Name Type Description Default value
enabled boolean Shows the filter true when an object is passed
container HTMLElement or string Element, or CSS selector, to render the filter into inside the seat plan container
layout string top-panel or left-panel left-panel
appearance string inline or panel

Events

The seating plan talks to your page through the callback functions passed in the initialisation properties.

Name Argument Description
onSelectionChanged Seat[] Fired when a seat or GA ticket is selected or unselected. Receives the whole current selection
onSubmitRequested BasketSubmitPayload Fired when the customer presses Reserve and the selection passed validation
onPriceBandsChanged PriceBand[] Fired when availability is loaded or refreshed
onError SeatPlanError Fired when any seating plan error occurs
onSelectionChanged: function (selection) {
    console.log(selection)
    /* Output
    *  [
    *      { ticketId: '141745744', Row: 'F', Seat: '12', section: 'Stalls', price: 89.5, priceBand: 'B', ... },
    *      { ticketId: 'ga:811:0', isGeneralAdmission: true, generalAdmissionInventoryAreaId: 811,
    *        generalAdmissionLabel: 'Dance floor', price: 25, priceBand: 'GA', ... },
    *      { ticketId: 'ga:811:1', isGeneralAdmission: true, generalAdmissionInventoryAreaId: 811,
    *        generalAdmissionLabel: 'Dance floor', price: 25, priceBand: 'GA', ... }
    *  ]
    */
}

Seat

The selection has one entry per ticket. If the customer chooses 3 tickets in a GA area, the selection has 3 GA entries.

Name Type Description
ticketId string Ticket ID for a reserved seat. For a GA ticket, a temporary ID in the format ga:<areaId>:<index>, which must not be sent to the basket
Row string Row (reserved seats only)
Seat string Seat number (reserved seats only)
section string Section name (reserved seats only)
price number Price per ticket
facePrice number Face value
priceBefore number Price before discount, if discounted
priceBand string Price band
isOffer boolean The ticket is on offer
noBookingFee boolean The ticket has no booking fee
restrictedView boolean The seat has a restricted view
isGeneralAdmission boolean true for a GA ticket
generalAdmissionInventoryAreaId number GA area ID. The same as AreaId in Area Prices
generalAdmissionLabel string GA area name

BasketSubmitPayload

Name Type Description
ticketIds string[] Ticket IDs of the selected reserved seats. GA tickets are not included
generalAdmission GeneralAdmissionSelection[] Selected GA tickets, one entry per area. Not present when no GA tickets are selected
selection Seat[] The whole selection
validation ValidationResult The validation result

GeneralAdmissionSelection

Name Type Description
areaId number GA area ID
quantity number Number of tickets selected in the area
price number Price per ticket
priceBand string Price band
label string GA area name

PriceBand

Name Type Description
band string Price band ID
price number Price
color string Colour used on the plan
faceValue number Face value
priceBefore number Price before discount
isOffer boolean The band is on offer

SeatPlanError

Name Type Description
code number 0 unknown, 1 initialisation, 2 drawing, 10 fetching, 11 resources, 12 availability, 13 plan, 14 validation
category string unknown, initialization, rendering, network, configuration, validation or data
message string Error description
recoverable boolean true if the seating plan can still be used

Methods

createSeatPlanWithConfig returns a seat plan instance with the following methods.

Name Description
destroy() Removes the seating plan from the page. Call it before creating a new seating plan in the same container
getSelection() Returns the current selection (Seat[])
selectSeat(ticketId) Selects a seat
deselectSeat(ticketId) Unselects a seat or a GA ticket
submitSelection() Does the same as the Reserve button: validates the selection, then calls onSubmitRequested if it is valid. Use it if you hide the basket panel and show your own button
validateSelection() Validates the current selection, for example that no single empty seats are left between selected seats
refreshAvailability() Loads availability again
setActivePriceBands(bands) Shows only the given price bands. Pass 'all' to show all
togglePriceBand(band) Applies one click from your own legend. 'all' clears the filter, 'offer' toggles offer bands, any other value toggles that band. Returns the active bands
getPriceBandList() Returns the price bands (PriceBand[])
resetView() Resets zoom and position

Booking the selected tickets

When onSubmitRequested is called, add the tickets to the basket from your server. Your API key must never be sent to the browser.

  1. Create a basket if the customer does not have one.
  2. Call Add Tickets to Basket (v3) once, with both reserved and GA tickets:
POST https://api.londontheatredirect.com/v3/baskets/{basketId}/performances/{performanceId}/tickets
BasketSubmitPayload Request data
ticketIds (as integers) ReservedSeating
generalAdmission[].areaId UnreservedSeating[].AreaId
generalAdmission[].quantity UnreservedSeating[].Count
generalAdmission[].price UnreservedSeating[].Price

Leave out ReservedSeating when ticketIds is empty, and UnreservedSeating when generalAdmission is not present.

onSubmitRequested: function (payload) {
    var body = {}

    if (payload.ticketIds.length) {
        body.ReservedSeating = payload.ticketIds.map(Number)
    }

    if (payload.generalAdmission) {
        body.UnreservedSeating = payload.generalAdmission.map(function (area) {
            return { AreaId: area.areaId, Count: area.quantity, Price: area.price }
        })
    }

    // Your own endpoint, which calls Add Tickets to Basket (v3) with your API key
    return fetch('/my-basket/performances/' + performanceId + '/tickets', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(body),
    })
}

The request for the selection above:

{
    "ReservedSeating": [141745744],
    "UnreservedSeating": [
        { "AreaId": 811, "Count": 2, "Price": 25 }
    ]
}

Handling the result

Result What to do
Success All tickets were added. Continue to checkout
PartialSuccess Some tickets were added. ReservedTicketsError and UnreservedTicketsErrors say which were not and why. Tell the customer before they continue
Any other result No tickets were added. Show the error, call refreshAvailability() and let the customer choose again

Migrating from V1

V1 V2
LTD.SeatPlan.init({ clientId, performanceId }) Seatplan.createSeatPlanWithConfig(container, { request: { clientId, performanceId }, httpConfig })
ltd-seatplan element Any element with a height, passed as container
ltd-legend element with filterPriceBands filterPanel
ltd-basket element basketPanel
ltd-seatplan__preloader element Built in
LTD.Basket.OnSubmit event onSubmitRequested callback
LTD.SeatPlan.OnSeatSelected / OnSeatUnselected events onSelectionChanged callback
LTD.SeatPlan.OnError event onError callback
event.doubletapZoom, event.scrollMove config.doubleTapZoom, config.scrollMove
behavior.formatPrice config.formatPrice
i18n config.strings
GA areas drawn as individual seats GA areas drawn as one area with a quantity
Add Tickets to Basket with Tickets or BestSeats Add Tickets to Basket (v3) with ReservedSeating and/or UnreservedSeating in one call

To keep your existing V1 event handlers while you migrate, set config.enableLegacyEvents: true. The seating plan then also fires the V1 LTD.SeatPlan.* and LTD.Basket.OnSubmit DOM events on document. Their e.detail.ticketIds contains reserved seats only, so use onSubmitRequested to book GA tickets.

Mobile devices

The seating plan supports touch out of the box: pinch to zoom, drag to move, and double tap to zoom in.

Unlike V1, the seating plan is not fixed-positioned on touch devices and gets no extra class. It stays in your layout and fills its container. On small screens, give the container a height based on the viewport so the plan is large enough to use:

<style>
    #ltd-seatplan-v2 {
        height: 600px;
    }

    @media (max-width: 767px) {
        #ltd-seatplan-v2 {
            height: calc(100vh - 6rem);
        }
    }
</style>

Full Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
        <meta name="viewport" content="width=device-width, initial-scale=1" />

        <!-- Seat Plan V2 styles -->
        <link rel="stylesheet" href="https://seatplan-prod-bahjatbefnc9h6a7.a01.azurefd.net/seatplan.css" />

        <style>
            #ltd-seatplan-v2 {
                height: 600px;
            }

            @media (max-width: 767px) {
                #ltd-seatplan-v2 {
                    height: calc(100vh - 6rem);
                }
            }
        </style>
    </head>
    <body>
        <!-- Price band filter (optional) -->
        <div id="ltd-seatplan-v2-filter"></div>

        <!-- Main Seat Plan element -->
        <div id="ltd-seatplan-v2"></div>

        <!-- Basket panel with Reserve button (optional) -->
        <div id="ltd-seatplan-v2-basket"></div>

        <!-- Main script file -->
        <script src="https://seatplan-prod-bahjatbefnc9h6a7.a01.azurefd.net/seatplan.iife.js"></script>

        <!-- Initialisation script -->
        <script>
            (function (Seatplan) {
                var performanceId = 'performance-id';

                var seatPlan = Seatplan.createSeatPlanWithConfig(
                    document.getElementById('ltd-seatplan-v2'),
                    {
                        request: {
                            performanceId: performanceId,
                            clientId: 'your-client-id',
                            locale: 'en-GB',
                        },
                        httpConfig: {
                            baseUrl: 'https://spdp.londontheatredirect.com',
                            availabilityQueryMode: 'legacy',
                        },
                        config: {
                            margin: 24,
                            canvasFillMethod: 'contain',
                            limitSelectedSeats: 10,
                            scrollMove: true,
                            filterPanel: { container: '#ltd-seatplan-v2-filter', layout: 'top-panel' },
                            basketPanel: { container: '#ltd-seatplan-v2-basket', layout: 'sidebar' },
                        },
                        onSelectionChanged: function (selection) {
                            console.log('Selected tickets', selection.length);
                        },
                        onError: function (error) {
                            console.error('Seat plan error', error.message);
                        },
                        onSubmitRequested: function (payload) {
                            var body = {};

                            if (payload.ticketIds.length) {
                                body.ReservedSeating = payload.ticketIds.map(Number);
                            }

                            if (payload.generalAdmission) {
                                body.UnreservedSeating = payload.generalAdmission.map(function (area) {
                                    return { AreaId: area.areaId, Count: area.quantity, Price: area.price };
                                });
                            }

                            // Your own endpoint, which calls Add Tickets to Basket (v3) with your API key
                            return fetch('/my-basket/performances/' + performanceId + '/tickets', {
                                method: 'POST',
                                headers: { 'Content-Type': 'application/json' },
                                body: JSON.stringify(body),
                            })
                                .then(function (response) { return response.json(); })
                                .then(function (result) {
                                    if (result.Result === 'Success' || result.Result === 'PartialSuccess') {
                                        if (result.Result === 'PartialSuccess') {
                                            alert('Some selected tickets could not be added. Review the tickets in your basket before paying.');
                                        }
                                        window.location.href = '/checkout';
                                    } else {
                                        alert('Sorry, these tickets are no longer available.');
                                        seatPlan.refreshAvailability();
                                    }
                                });
                        },
                    }
                );
            }(window.Seatplan));
        </script>
    </body>
</html>