Availability Rate Results Component
The availability-rate-results component shows one rate across several entries. For the visitor’s search it lists every entry with its price and whether it’s available, booked or not offered. The visitor picks an available entry, adds extras and options, and books that entry with the rate through the normal checkout. Added in v6.7.0.
Use it when the thing visitors book is the rate, not the entry. On a boat charter site, each cruise is a shared rate on the boats collection: a cruise page lists the boats that sail it, and the visitor picks the boat.
Adding the component
Put it on the page with an availability-search that has no entry:
{{ livewire:availability-search }}
{{ livewire:availability-rate-results rate="full-day" :entries="boats" showExtras="true" }}
rate takes the rate’s ID or its slug. entries takes an Entries field, such as boats above, so a cruise entry can list the boats that sail it. It also takes entry IDs, as an array or a comma-separated list. Leave entries out to list every entry the rate applies to, in title order. Either way, only the entries published and public on the visitor’s site are listed: an entry’s localization there, or the entry itself when it has none.
The rate’s restrictions apply as usual. Set the rate’s Date range to the season the cruise runs.
To show on the calendar which days any entry can take the rate, and from what price, pass the same rate and entries to the search:
{{ livewire:availability-search showAvailabilityOnCalendar="true" rate="full-day" :entries="boats" }}
See One rate across several entries.
What each entry shows
| Status | When | Shows |
|---|---|---|
| Available | The entry can be booked with the rate for the search. | The price and a Choose button. |
| Booked | The entry has a price for every day of the search, but no stock left, or the rate’s Max available is reached. | The price, struck through. |
| Not offered | The entry has no price for every day of the search: the rate doesn’t apply to it, the dates are outside the rate’s restrictions, the entry is disabled, or no price was set. | No price. |
For a rate that takes stock from several base rates, an entry is available only while every block the rate takes has stock.
Booking
When the visitor presses Choose, the entry’s extras and options appear (with showExtras and showOptions on) and a Book now button. Book now creates a pending reservation for the chosen entry with the component’s rate, at the price the visitor saw, and takes them to the checkout. Payment, extras, options, events and emails then work as for any other reservation.
Choosing another entry clears the extras and options picked for the first one, because they belong to the entry.
The server checks every choice:
- Only an entry the search found available with the rate can be chosen. An entry outside
entries, one the rate doesn’t apply to, one that’s unpublished or private on the visitor’s site, or one that’s booked is refused with an error. Book now refuses it too if it was unpublished after the visitor chose it. - The rate, the list of entries, the rows and the chosen entry can’t be changed from the browser.
- Book now books the component’s rate, whatever rate the search carries.
- If the entry was booked or its price changed since the search, Book now shows an error and creates nothing.
- A new search keeps the chosen entry while it’s still available, and clears it otherwise.
Properties
| Property | Default | Description |
|---|---|---|
rate |
The rate’s ID, or its slug in the entries’ collection. Required. | |
entries |
Every entry the rate applies to | An Entries field, or entry IDs as an array or a comma-separated list. On a multisite, pass default-site IDs or their localizations. |
showExtras |
false |
Shows the chosen entry’s extras: true for all, or an array of extra IDs. |
showOptions |
false |
Shows the chosen entry’s options: true for all, or an array of option IDs. |
view |
availability-rate-results |
A custom view in resources/views/vendor/statamic-resrv/livewire. |
In a custom view, these are available:
| Name | Description |
|---|---|
$rows |
entry ID => ['status', 'price', 'original_price', 'payment'], with status one of available, booked or not_offered. |
$this->entries |
The listed entries in the current site, keyed by their default-site ID. |
$entryId |
The chosen entry’s ID, or null. |
$rateId |
The rate’s ID. |
selectEntry('<id>') |
Chooses an entry. |
checkout() |
Books the chosen entry. |
Events
| Event | Sent when | Data |
|---|---|---|
availability-entry-selected |
The visitor chooses an entry. | entryId and rateId. |
availability-results-updated |
The rows are redrawn. | entryId (the chosen entry, or null), resultsId (the component’s Livewire ID), rateId and search. |
Like availability-results, it runs the init, availability-search-updated and availability-results-updated Statamic hooks.
Translations
The statuses and buttons use these frontend.php keys: entryAvailable, entryBooked, entryNotOffered, chooseEntry, entryChosen, entryNotAvailable and selectAnEntry. The search calendar labels booked days with dateBooked. See Languages.
Customizing
Publish the views with php artisan vendor:publish --tag=resrv-checkout-views, then edit resources/views/vendor/statamic-resrv/livewire/availability-rate-results.blade.php.
If your view renders the extras or options components itself, pass them :entryId="$entryId", :resultsId="$this->getId()" and :effectiveRateId="$rateId", as the package’s view does, so they price under the component’s rate and follow its searches.
Related
- Availability Results: one entry, with every rate it has.
- Rates: shared rates and time blocks.
- Availability Collection: many entries, each with its cheapest rate.