automator_amelia_appointment_booked
Fires after a booking is successfully made within the Amelia Booking plugin, providing normalized appointment data.
add_action( 'automator_amelia_appointment_booked', $callback, 10, 1 );
Description
Fires after an Amelia appointment is successfully booked. Developers can use this hook to perform custom actions, such as sending notifications or updating other systems, based on the appointment details. The `$normalized_data` parameter contains structured information about the booked appointment.
Usage
add_action( 'automator_amelia_appointment_booked', 'your_function_name', 10, 1 );
Parameters
-
$normalized_data(mixed) - This parameter contains the normalized data representing a booked Amelia appointment, which is a structured format of the booking details.
Examples
<?php
/**
* Example function to handle the automator_amelia_appointment_booked hook.
*
* This function will be executed whenever an Amelia appointment is booked.
* It receives normalized appointment data and can be used to perform
* custom actions, such as logging, sending notifications, or updating
* other systems.
*
* @param array $normalized_data An array containing normalized data about the booked appointment.
* The exact structure depends on the normalization logic in
* `extract_normalized_data()`, but it might include details like:
* - 'appointment_id'
* - 'customer_email'
* - 'service_name'
* - 'booking_date'
* - 'booking_time'
* - 'employee_name'
* - 'payment_status'
*/
add_action( 'automator_amelia_appointment_booked', function( $normalized_data ) {
// Check if we have valid appointment data.
if ( ! is_array( $normalized_data ) || empty( $normalized_data ) ) {
error_log( 'automator_amelia_appointment_booked: Received empty or invalid normalized data.' );
return;
}
// Log the appointment booking for debugging purposes.
// In a real-world scenario, you might perform more complex actions here.
$log_message = sprintf(
'Amelia Appointment Booked: ID=%s, Customer Email=%s, Service=%s, Date=%s, Time=%s',
isset( $normalized_data['appointment_id'] ) ? $normalized_data['appointment_id'] : 'N/A',
isset( $normalized_data['customer_email'] ) ? $normalized_data['customer_email'] : 'N/A',
isset( $normalized_data['service_name'] ) ? $normalized_data['service_name'] : 'N/A',
isset( $normalized_data['booking_date'] ) ? $normalized_data['booking_date'] : 'N/A',
isset( $normalized_data['booking_time'] ) ? $normalized_data['booking_time'] : 'N/A'
);
// You could also check for specific conditions, e.g., payment status.
if ( isset( $normalized_data['payment_status'] ) && $normalized_data['payment_status'] === 'paid' ) {
$log_message .= ' (Payment Status: Paid)';
// Perform actions specific to paid appointments, e.g., trigger an invoice.
}
error_log( $log_message );
// Example: If this were a filter, you would return a modified value.
// For example:
// return $modified_data;
}, 10, 1 ); // Priority 10, accepts 1 argument.
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/integrations/ameliabooking/helpers/ameliabooking-helpers.php:485
src/integrations/ameliabooking/helpers/ameliabooking-helpers.php:509
public function normalize_booking_data( $data, $container = null ) {
if ( empty( $data ) ) {
return;
}
$normalized_data = $this->extract_normalized_data( $data );
if ( ! empty( $normalized_data ) ) {
do_action( 'automator_amelia_appointment_booked', $normalized_data );
}
}
Internal Usage
Found in src/integrations/ameliabooking/triggers/amelia-appointment-booked.php:53:
$this->add_action( 'automator_amelia_appointment_booked' ); // which do_action() fires this trigger
Found in src/integrations/ameliabooking/triggers/amelia-user-appointment-booked.php:52:
$this->add_action( 'automator_amelia_appointment_booked' ); // which do_action() fires this trigger
Found in uncanny-automator-pro/src/integrations/ameliabooking/triggers/amelia-user-appointment-booked-service.php:54:
$this->add_action( 'automator_amelia_appointment_booked' );
Found in uncanny-automator-pro/src/integrations/ameliabooking/triggers/amelia-appointment-booked-service.php:54:
$this->add_action( 'automator_amelia_appointment_booked' );