home > support > API > Marketplace API > check option availability
Check for Option availability
Options are ancillary items that are sold on top of a Tour.
Generally Options are added to a booking at the same time as the Tour they are associated with (see Check Tour Availability and then either Start New Booking or Add Booking Component), however this endpoint allows you to obtain a key that can be used to add an Option to an exsting Tour booking (via Add Booking Component).
For use by Tour Operator accounts only, agents cannot add Options to existing bookings via the API
Endpoint | /c/booking/options/checkavail |
Formats | XML |
Example | /c/booking/options/checkavail.xml?booking_id=1234&tour_component_id=6789 |
Verb | GET |
PHP examples use the PHP Client Library with SimpleXML
object check_option_availability ( int $booking, int $tour_component_id, int $channel )
// Set the channel this booking will be made with.
$channel = 3930;
// The ID for the booking the component is on
$booking = 1234;
// Set the ID for the existing Tour component (component_id from departure component) to check for Options on, found via Show Booking.
$tour_component_id = 6789;
// Query the TourCMS API, checking for Option availability
$result = $tourcms->check_option_availability($booking, $tour_component_id, $channel);
// See how many available options TourCMS has returned
if(isset($result->available_components->options->option))
$num_options = count($result->available_components->options->option);
else
$num_options = 0;
// If there are options display them, otherwise display "no availability"
if($num_options>0) {
// We have some options, loop through them
foreach ($result->available_components->options->option as $item)
{
print "\xA";
print "Name: $item->option_name";
print "\xA";
print "Short description: $item->short_description";
}
} else {
// The options we searched for are not available
print "Sorry, no availability";
}
Name: Option 1
Short description: This is the short descrition for the option 1
C# examples use the .Net Client Library
Code sample here soon
VB examples use the .Net Client Library
Code sample here soon
NodeJS examples use the NodeJS Wrapper
// Check for Option availability
TourCMS.checkOptionAvailability({
channelId: 3930,
qs: {
booking_id: 12662,
tour_component_id: 8052295
},
callback: function(response) {
//console.info(response.available_components.options.option);
var options = [].concat(response.available_components.options.option);
[].forEach.call(options, function(opt) {
console.log("Option: "+opt.option_name);
[].forEach.call(opt.quantities_and_prices.selection, function(sel) {
console.log(" Quantities possible: "+sel.quantity);
});
});
}
});
Option: Test option
Quantities possible: 1
Quantities possible: 2
Quantities possible: 3
Quantities possible: 4
Looking for sample code in a different language? TourCMS and community provided API libraries
Parameter | Notes |
---|---|
booking_id | The ID for the booking the existing Tour component is on |
tour_component_id | The ID for the existing Tour component to check for Options on, found via Show Booking |
The Channel ID is also passed via the request header.
XML Node | Notes | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request | Confirmation of the request that you sent | ||||||||||||||||||||||||||||||||||||||||||||||||
error | Any error message returned, if there is no error this will just contain the text OK | ||||||||||||||||||||||||||||||||||||||||||||||||
channel_id | Channel ID | ||||||||||||||||||||||||||||||||||||||||||||||||
account_id | Account ID | ||||||||||||||||||||||||||||||||||||||||||||||||
component_key_valid_for | How long (in seconds) the returned component keys will be valid for. While valid TourCMS will hold the price (but not the availability). If this time period elapses prior to booking, a new component-key should be retrieved. Currently will always return 3600 seconds (1 hour) however TourCMS may adjust this value in the future |
||||||||||||||||||||||||||||||||||||||||||||||||
available_ components |
An available_components node, it may be empty if there's no availability, otherwise it will contain:
|