Action uncanny-automator-pro

automator_ameliabooking_status_updated

Fires after Amelia Booking reservation status is updated, passing reservation and booking details for customization.

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

Description

Fires after an AmeliBooking status update for each booking. Developers can use this hook to trigger Automator recipes or execute custom actions based on changes to booking statuses, passing reservation details, the specific booking, and the container object.


Usage

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

Parameters

$reservation (mixed)
This parameter contains information about the specific reservation that had its status updated.
$booking (mixed)
This parameter contains the Ameli Booking reservation object for the updated booking.
$container (mixed)
This parameter represents the entire collection of bookings associated with the reservation.

Examples

add_action( 'automator_ameliabooking_status_updated', 'my_ameliabooking_status_update_handler', 10, 3 );

/**
 * Handles updates to Amelia Booking statuses.
 *
 * This function is hooked into the 'automator_ameliabooking_status_updated' action
 * and demonstrates how to process booking status changes from Amelia.
 *
 * @param mixed $reservation The primary reservation object or data.
 * @param mixed $booking     The specific booking item that was updated.
 * @param mixed $container   Additional context or container data.
 */
function my_ameliabooking_status_update_handler( $reservation, $booking, $container ) {

	// Basic check to ensure we have relevant booking data.
	// In a real-world scenario, you'd check for specific statuses or data points.
	if ( ! is_array( $booking ) || empty( $booking['status'] ) ) {
		error_log( 'my_ameliabooking_status_update_handler: Invalid booking data received.' );
		return;
	}

	$booking_status = sanitize_text_field( $booking['status'] );
	$booking_id     = isset( $booking['id'] ) ? intval( $booking['id'] ) : 0;

	// Example: Log the booking ID and its new status.
	// You could also use this to trigger other automations, send notifications,
	// update custom fields, etc.
	if ( $booking_id > 0 ) {
		error_log( sprintf( 'Amelia Booking Status Update: Booking ID %d status changed to "%s".', $booking_id, $booking_status ) );

		// Example: If the booking is now 'approved', you might want to perform an action.
		if ( 'approved' === $booking_status ) {
			// Potentially notify the customer or administrator.
			// wp_mail( '[email protected]', 'Amelia Booking Approved', 'Booking ' . $booking_id . ' has been approved.' );
			error_log( sprintf( 'Amelia Booking Approved: Performing further actions for booking ID %d.', $booking_id ) );
		}

		// Example: If the booking is now 'canceled', you might want to update another system.
		if ( 'canceled' === $booking_status ) {
			// Example: Update a custom post meta.
			// update_post_meta( $booking_id, '_amelia_booking_status', 'canceled' );
			error_log( sprintf( 'Amelia Booking Canceled: Performing cleanup or further actions for booking ID %d.', $booking_id ) );
		}
	}
}

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:51

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

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


Scroll to Top