Home /Tutorials /Canceling a reservation
Canceling a reservation

To cancel a reservation, you’ll need the user’s key (uid), the date and time in GMT, and either the appointment or class period key. There are a few ways to retrieve this information, but this tutorial assumes the user is already known.

The first call must be made to the PageListModel endpoint to retrieve a list of upcoming visit keys.

// Retrieve the list of upcoming visits.
$o_page_model = new \WellnessLiving\Wl\Schedule\Page\PageListModel($o_config);
$o_page_model->cookieSet($o_notepad->cookieGet()); // Store cookies to maintain the session.

$o_page_model->k_business='3';
$o_page_model->dtu_start = '2023-03-27 00:00:00';
$o_page_model->dtu_end = '2023-03-31 00:00:00';
$o_page_model->uid = '4';

$o_page_model->get();

// Print the visit keys.
foreach($o_page_model->a_visit as $a_visit)
{
 echo $a_visit['k_visit']."\n";
}

In the list of upcoming visits, find the visit you want to cancel. The PageElementModel endpoint takes one visit key at a time. From this visit, you can gather all the other required information.

// Retrieve the details of a visit.
$o_page_model = new \WellnessLiving\Wl\Schedule\Page\PageElementModel($o_config);
$o_page_model->cookieSet($o_notepad->cookieGet()); // Store cookies to maintain the session.

$o_page_model->k_visit='246';
$o_page_model->get();

// Print information about a visit.
echo 'Date: '.$o_page_model->dt_date_global."\n";
if($o_page_model->k_appointment)
 echo 'Appointment key: '.$o_page_model->k_appointment."\n";
if($o_page_model->k_class_period)
 echo 'Appointment key: '.$o_page_model->k_class_period."\n";
echo 'User key: '.$o_page_model->uid."\n";

Using the information gathered, you can cancel the visit using the CancelModel endpoint.

// Cancel an upcoming visit.
$o_cancel_model = new \WellnessLiving\Wl\Schedule\CancelModel($o_config);
$o_cancel_model->cookieSet($o_notepad->cookieGet()); // Store cookies to maintain the session.

$o_cancel_model->dt_date='2023-03-27 14:30:00';
$o_cancel_model->is_backend=true;
$o_cancel_model->k_appointment='49';
$o_cancel_model->uid='4';

$o_cancel_model->get();

// If successful, the visit is canceled.
echo "Cancellation complete\n";