Action uncanny-automator-pro

automator_ameliabooking_status_cancelled

Fires when an Amelia booking is cancelled, providing access to reservation, booking, and container data.

add_action( 'automator_ameliabooking_status_cancelled', $callback, 10, 3 );

Description

Fired after an Amelia booking status changes to 'cancelled'. Developers can use this hook to execute custom logic or integrations when an appointment is cancelled. It passes the reservation details, the specific cancelled booking, and the container object. This hook fires for each individual booking within a cancelled reservation.


Usage

add_action( 'automator_ameliabooking_status_cancelled', 'your_function_name', 10, 3 );

Parameters

$reservation (mixed)
This parameter likely contains information about the specific reservation that has been cancelled.
$booking (mixed)
This parameter contains the reservation object for a cancelled Ameli Booking appointment.
$container (mixed)
This parameter contains an array of booking objects related to the cancelled reservation.

Examples

<?php
/**
 * Example function to handle the automator_ameliabooking_status_cancelled action hook.
 * This function would typically be used to update internal records or notify users
 * when an Amelia Booking appointment is cancelled.
 *
 * @param array $reservation The Amelia Booking reservation object.
 * @param object $booking     The specific booking object within the reservation.
 * @param object $container   The container object, potentially holding app context.
 */
function my_ameliabooking_cancelled_handler( $reservation, $booking, $container ) {
    // Ensure we have valid data before proceeding.
    if ( ! is_array( $reservation ) || ! is_object( $booking ) || ! is_object( $container ) ) {
        error_log( 'Invalid data passed to my_ameliabooking_cancelled_handler.' );
        return;
    }

    // Example: Log the cancellation details.
    $user_email = isset( $reservation['email'] ) ? $reservation['email'] : 'N/A';
    $appointment_date = isset( $booking->date ) ? $booking->date : 'N/A';
    $service_name = isset( $booking->service_name ) ? $booking->service_name : 'N/A';

    error_log( sprintf(
        'Amelia Booking Cancelled: User Email: %s, Date: %s, Service: %s',
        $user_email,
        $appointment_date,
        $service_name
    ) );

    // Example: Update a custom post meta for the cancelled appointment.
    // Assuming you have a way to map $booking->id to a WordPress post ID.
    // For demonstration purposes, let's assume a function `get_post_id_from_booking_id` exists.
    // $post_id = get_post_id_from_booking_id( $booking->id );
    // if ( $post_id ) {
    //     update_post_meta( $post_id, '_amelia_booking_status', 'cancelled' );
    // }

    // Example: Send a notification to an admin.
    // $admin_email = get_option( 'admin_email' );
    // if ( $admin_email ) {
    //     wp_mail(
    //         $admin_email,
    //         'Amelia Booking Cancelled - ' . $service_name,
    //         sprintf(
    //             'An Amelia Booking for "%s" on %s by %s has been cancelled.',
    //             $service_name,
    //             $appointment_date,
    //             $user_email
    //         )
    //     );
    // }
}

// Add the action hook with the handler function.
// The third parameter '3' indicates that the hooked function will accept 3 arguments.
add_action( 'automator_ameliabooking_status_cancelled', 'my_ameliabooking_cancelled_handler', 10, 3 );
?>

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

uncanny-automator-pro/src/integrations/ameliabooking/helpers/ameliabooking-pro-helpers.php:69

public function ameliabooking_status_cancelled( $reservation, $bookings, $container ) {

		// Delegate the action to the automator_ameliabooking_status_cancelled action hook.
		foreach ( $bookings as $booking ) {
			// Fires the trigger for each booking.
			do_action( 'automator_ameliabooking_status_cancelled', $reservation, $booking, $container );
		}
	}


Internal Usage

Found in uncanny-automator-pro/src/integrations/ameliabooking/triggers/amelia-user-appointment-booked-service-cancelled.php:61:

$this->add_action( 'automator_ameliabooking_status_cancelled' );

Found in uncanny-automator-pro/src/integrations/ameliabooking/triggers/amelia-appointment-booked-service-cancelled.php:62:

$this->add_action( 'automator_ameliabooking_status_cancelled' );
Scroll to Top