home > support > API > add booking component
Add a Tour (with or without Options) to a booking, or add Options to an existing Tour that is already on a booking.
Bookings should be non-temporary (i.e. should be committed), non-archived.
For use by Tour Operators only. Marketplace Agents cannot add components to an existing booking, instead they should submit a "Modify" booking note, or potentially cancel and re-book.
This API call is intended for adding products to existing bookings. If instead you are building a shopping cart, you should supply all componenents to Start New Booking.
Endpoint | /c/booking/component/new |
Formats | XML |
Example | URL: /c/booking/component/new.xml POST data:
|
Verb | POST |
PHP examples use the PHP Client Library with SimpleXML
object booking_add_component ( SimpleXmlElement $component_data, int $channel )
// Set the channel this booking will be made with
$channel = 3930;
// Start building the booking XML
$component_data = new SimpleXMLElement('<booking />');
// Set the ID for the booking of the tour or options are on
$component_data->addChild('booking_id', 'BOOKING_ID_HERE');
// Add a component node
$child_component_data = $component_data->addChild('component');
// Either:
// If adding a Tour (with or without Options) a component_key for the component to add,
// obtained via a call to the Check Tour availability API method
// or:
// If adding Options to a Tour component already on the booking,
// rather than a key pass the text "ADD_OPTION_TO_EXISTING_TOUR" (without quotes)
$child_component_data->addChild('component_key', 'COMPONENT_KEY_HERE');
// Query the TourCMS API, adding a tour or options to an existing Tour
$result = $tourcms->booking_add_component($component_data, $channel);
// Check the result, will be "OK" if the tour or options were added
switch ($result->error) {
case "OK":
// Print a success message
print "Thanks, your tour or options have been added.";
break;
default:
// Some other problem (could check error to see what)
print "Sorry, unable to add the tour or options at this time.";
break;
}
Thanks, your tour or options to an existing tour have been added.
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
// Add a component to a booking
TourCMS.addBookingComponent({
channelId: 3930,
booking: {
booking_id: 12920,
component: {
component_key: 'Rjqb+vKn6H5rawI+mt/m56vQ9P6ju1aKv2XO9gZ2OxykgCsUAbrdap/7CTxDKl+p'
}
},
callback: function(response) {
console.log(response.error);
}
});
OK
Looking for sample code in a different language? TourCMS and community provided API libraries
Enter your TourCMS API credentials below to call the Add Booking Component endpoint.
Take care, submitting this form will modify live data!
XML Node | Notes | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
booking |
The root XML element
|
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. |