Okay
  Public Ticket #2945238
JavaScript Hook
Closed

Comments

  •  1
    Gordon started the conversation

    Hello there,


    I would like to hook into the cancellation function to run my own script when someone cancels a booking. I know you don't have any PHP hooks or filters, but I did find a support ticket on the WordPress Support Repository that states you have JavaScript hooks. Could you please let me know what that may be? Best regards,

    Gordon

  • [deleted] replied

    Hi Gordon

    Thank you for purchasing Amelia, and for reaching out to us.

    Unfortunately we don't have hooks (action and filters) at the moment. What we have is a few JS hooks that is triggered depends on the view:

    window.beforeAddToCalendarLoaded()
    window.beforeBookingLoaded()
    window.beforeSearchLoaded()
    window.beforeSearchFiltered()
    window.afterSearchFiltered()
    window.beforeConfirmedBooking()
    window.beforeCatalogLoaded()
    window.afterSelectCatalogCategory(object_category)
    window.beforeCatalogCategoryLoaded(object_category)
    window.beforeCatalogServiceLoaded(object_category, object_service)
    window.afterSearchActivateService(object_appointment, object_serviceActive)
    window.afterSearchGoToSecondStep(object_appointment, object_serviceActive)
    window.afterBookingSelectDateAndTime(object_appointment, object_serviceId, object_providerId, object_locationId)
    window.afterBookingSelectService(object_appointment, object_serviceId, object_providerId, object_locationId)
    window.beforeConfirmBookingLoaded(object_appointment, object_service, object_provider, object_location)
    window.afterConfirmBooking(object_appointment, object_service, object_provider, object_location)

    JS files are modified (minimized) in public version of plugin (in our development environment is accessible), but unfortunately I can not send you our source code because that is the policy of our company.

    All those files that have extension .vue are compressed and minimized in JS files that is very hard and not recommended modifying. So in order to add some other features you can unminify the js and customize it.

    In the CancelBooking webhook we forward the endpoint, but the URL needs to contain the cancellation token (which can be found in that webhook).

    Have a nice day!

  •  3
    Alexander replied

    @elena: Another post says there are hooks: https://tmsplugins.ticksy.com/ticket/2591394/

    <?php
    function amelia_booking_added_hook($reservation, $bookings, $container) {
    }
    add_action('AmeliaBookingAdded', 'amelia_booking_added_hook', 10, 3);
    function amelia_booking_time_updated_hook($reservation, $bookings, $container) {
    }
    add_action('AmeliaBookingTimeUpdated', 'amelia_booking_time_updated_hook', 10, 3);
    function amelia_booking_status_updated_hook($reservation, $bookings, $container) {
    }
    add_action('AmeliaBookingStatusUpdated', 'amelia_booking_status_updated_hook', 10, 3);
    function amelia_booking_canceled_hook($reservation, $bookings, $container) {
    }
    add_action('AmeliaBookingCanceled', 'amelia_booking_canceled_hook', 10, 3);
    ?>

  • [deleted] replied

    Hi Alexander

    Yes, this actions will be executed before our WebHook (Amelia Settings -> Integrations -> WebHook) is executed.

    First parameter is appointment, second is booking.

    Please feel free to open a new ticket if you need some further assistance.