home > support > API > Marketplace API > update customer
Update the details on a customer record
Tour Operators can update any customer, travel agents with permission level 3 (full data access to own data) can update customer records that they originally created, except for custom fields or the customer_username, customer_password fields.
Useful for updating the contact details on a customer created as part of a temporary or even committed booking, perhaps if customer details weren't known at the time.
Could also be used by Tour Operators perhaps combine with the Customer Login Search to create a way for customers to log in and update their contact / marketing preferences.
Call | /c/customer/update |
Formats | XML |
Example | URL: /c/customer/update.xml POST data:
|
Verb | POST |
PHP examples use the PHP Client Library with SimpleXML
object update_customer ( SimpleXmlElement $customer_data, int $channel )
// Set the channel ID
$channel = 3;
// Create a new SimpleXMLElement to hold the customer details
$customer = new SimpleXMLElement('<customer />');
// Must set the Customer ID on the XML, so TourCMS knows
// who to update
$customer->addChild('customer_id', '12345');
// Provide a new email address, perhaps they filled in a form
// saying they had changed it
$customer->addChild('email', 'joe.bloggs@example.com');
// Call TourCMS API, updating the customer
$result = $tourcms->update_customer($customer, $channel);
// Check the result, will be "OK" if a customer was updated
switch ($result->error) {
case "OK":
// Print a success message
print "Thanks, your details have been updated";
break;
case "NO DATA CHANGED":
// Nothing was changed, old data matched new data
print "Thanks, it looks like we have your correct address already!";
break;
default:
// Some other problem (could check error to see what)
print "Sorry, unable to update your details at this time";
break;
}
Thanks, your details have been updated
C# examples use the .Net Client Library
XmlDocument UpdateCustomer (XmlDocument customerDetails, int channelId)
// ID for the channel (supplier) the customer belongs to
int channelId = 3;
// Create an XMLDocument to hold the customer details
XmlDocument customer = new XmlDocument();
// Create the XML Declaration, append it to XML document
XmlDeclaration dec = customer.CreateXmlDeclaration("1.0", null, null);
customer.AppendChild(dec);
// Create the root element, append it to the XML document
XmlElement root = customer.CreateElement("customer");
customer.AppendChild(root);
// Must set the Customer ID on the XML, so TourCMS knows
// who to update
XmlElement customerId = customer.CreateElement("customer_id");
customerId.InnerText = "12345";
root.AppendChild(customerId);
// Provide a new email address, perhaps they filled in a form
// saying they had changed it
XmlElement email = customer.CreateElement("email");
email.InnerText = "joe.bloggs@example.com";
root.AppendChild(email);
// Call the API
XmlDocument doc = myTourCMS.UpdateCustomer(customer, channelId);
// Get the response status, will be "OK" if TourCMS updated the customer
// or "NO DATA CHANGED" if the new data matched the existing data
string status = doc.SelectSingleNode("//error").InnerText;
Console.WriteLine(status);
OK
VB examples use the .Net Client Library
XmlDocument UpdateCustomer (XmlDocument customerDetails, Integer channelId)
' ID for the channel (supplier) the customer belongs to
Dim channelId As Integer = 3;
' Create an XMLDocument to hold the customer details
Dim customer As XmlDocument = new XmlDocument()
' Create the XML Declaration, append it to XML document
Dim dec As XmlDeclaration = customer.CreateXmlDeclaration("1.0", null, null)
customer.AppendChild(dec)
' Create the root element, append it to the XML document
Dim root As XmlElement = customer.CreateElement("customer")
customer.AppendChild(root)
' Must set the Customer ID on the XML, so TourCMS knows who to update
Dim customerId As XmlElement = customer.CreateElement("customer_id")
customerId.InnerText = "12345"
root.AppendChild(customerId)
' Provide a new email address, perhaps they filled in a form
' saying they had changed it
Dim email As XmlElement = customer.CreateElement("email")
email.InnerText = "joe.bloggs@example.com"
root.AppendChild(email)
' Call the API
Dim doc As XmlDocument = myTourCMS.UpdateCustomer(customer, channelId)
' Get the response status, will be "OK" if TourCMS updated the customer
' or "NO DATA CHANGED" if the new data matched the existing data
Dim status As String = doc.SelectSingleNode("//error").InnerText
Console.WriteLine(status)
OK
NodeJS examples use the NodeJS Wrapper
// Change the first name for customer 12345 on Channel 3930 to "Joseph"
TourCMS.updateCustomer({
channelId: 3930,
customer: {
customer_id: 12345,
firstname: "Joseph"
},
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 Update Customer endpoint.
Take care, submitting this form will modify live data!
There are no querystring parameters.
The following fields can be posted as XML when calling the API, the customer_id is the only required field.
Any fields not present in the XML will not be updated, to clear a field you will need to add it to the XML but leave it's contents blank.
XML Node | Notes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
customer |
The root XML element, can contain any of the following child nodes.
|
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. If no data was updated (perhaps because the supplied data was the same as the existing data this will contain the text NO DATA CHANGED, you may wish to code for this and handle the same as an |
customer |
If the customer was found there will be a customer node containing the following child nodes.
|