So I have used the following to send the cancellation email

So I have used the following to send the cancellation email to the admin:

function my_app_email_on_appointment_cancelled ($app_id) {
global $appointments;
$to = $appointments->get_admin_email();
wp_mail($to, 'An appointment has been cancelled', "An appointment with ID {$app_id} has just been cancelled.");
}
add_action('app-appointments-appointment_cancelled', 'my_app_email_on_appointment_cancelled');

However, is it possible to customize it to look similar to the other emails sent (ie. the confirmation and reminder emails)?

Below is an example:

Dear Admin,

An appointment has been cancelled for SERVICE.

Here are the appointment details:

Name: CLIENT
Phone: PHONE
Email: EMAIL

Requested Game: SERVICE
Date and Time: DATE_TIME

Thanks a bunch!

  • Vaughan

    Hi @Cullan Liang,

    Not sure if it's possible without some custom code.

    I haven't tried or tested this but it may be possible by doing:

    function my_app_email_on_appointment_cancelled ($app_id) {
    global $appointments;
    $to = $appointments->get_admin_email();
    
    $app = $appointments->get_app($app_id);
    
    $message = "Dear Admin,/r/n
        An appointment has just been cancelled for SERVICE./n/n
    
        Here are the appointment details:/n/n
        NAME: CLIENT/n
        Phone: PHONE/n
        Email: EMAIL/n/n
        Requested Game: SERVICE/n
        Date and Time: DATE_TIME
    ";
    $body = $appointments->_replace( $message, $app->name, $appointments->get_service_name( $app->service), $appointments->get_worker_name( $app->worker),
    							$app->start, $app->price, $app->deposit, $app->phone, $app->note, $app->address, $app->email, $app->city );
    
    wp_mail($to, 'An appointment has been cancelled', $body);
    }
    add_action('app-appointments-appointment_cancelled', 'my_app_email_on_appointment_cancelled');

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.