Christmas shapes Christmas shapes
Santa's best deal Get up to 60  off! Get up to 60  off!
Grab the deal

Amelia JavaScript Hooks for Booking forms

Please note that using hooks requires a certain level of programming skills and included support refers only to advice. These hooks are only triggered on the new booking and catalog forms ([ameliastepbooking] and [ameliacatalogbooking])

Parameters

  • success function
    Success callback function. Only used for ‘beforeBooking’ hook
  • error function
    Error callback function. Only used for ‘beforeBooking’ hook
  • data object
    Appointment data object

Form loaded

The hook ‘ViewContent’ is triggered after the form has loaded

window.ameliaActions = {
  ViewContent: function (success = null, error = null, data) {
    console.log('ViewContent HOOK')
    console.log(data)
    console.log('------------')
  }
}

Service selected

The hook ‘SelectService’ is triggered when the service is selected/changed in the form

window.ameliaActions = {
  SelectService: function (success = null, error = null, data) {
    console.log('SelectService HOOK')
    console.log(data)
    console.log('------------')
  }
}

Category selected

The hook ‘SelectCategory’ is triggered when the category is selected/changed in the form

window.ameliaActions = {
  SelectCategory: function (success = null, error = null, data) {
    console.log('SelectCategory HOOK')
    console.log(data)
    console.log('------------')
  }
}

Employee selected

The hook ‘SelectEmployee’ is triggered when the employee is selected/changed in the form

window.ameliaActions = {
  SelectEmployee: function (success = null, error = null, data) {
    console.log('SelectEmployee HOOK')
    console.log(data)
    console.log('------------')
  }
}

Location selected

The hook ‘SelectLocation’ is triggered when the location is selected/changed in the form

window.ameliaActions = {
  SelectLocation: function (success = null, error = null, data) {
    console.log('SelectLocation HOOK')
    console.log(data)
    console.log('------------')
  }
}

Package selected

The hook ‘SelectPackage’ is triggered when the package is selected/changed in the form

window.ameliaActions = {
  SelectPackage: function (success = null, error = null, data) {
    console.log('SelectPackage HOOK')
    console.log(data)
    console.log('------------')
  }
}

Info step loaded

The hook ‘InitInfoStep’ is triggered when the customer information step is loaded

window.ameliaActions = {
  InitInfoStep: function (success = null, error = null, data) {
    console.log('InitInfoStep HOOK')
    console.log(data)
    console.log('------------')
  }
}

Custom validation on info step

The hook ‘customValidation’ is triggered when the customer information step is validated, before the payment step loads

window.ameliaActions = {
   customValidation: function (success = null, error = null, data) {
    console.log('customValidation HOOK')
    console.log('------------')
    console.log(data)
   
    const customValidator = (rule, value, callback) => {
      if (value.includes('SOME_REGEX')) {
        callback(new Error())
      } else {
        callback()
      }
    }
    // this example is for email input field
    data.rules.email.push({message: 'CUSTOM MESSAGE', validator: customValidator})

    // this example is for a custom field
    var customFieldId = 2
    data.rules['cf' + customFieldId].push({message: 'CUSTOM MESSAGE', validator: customValidator})

  }
}

Payment step loaded

The hook ‘InitiateCheckout’ is triggered when the payment step is loaded

window.ameliaActions = {
  InitiateCheckout: function (success = null, error = null, data) {
    console.log('InitiateCheckout HOOK')
    console.log(data)
    console.log('------------')
  }
}

Confirm button clicked

The hook ‘beforeBooking’ is triggered the “Confirm” button is clicked but before the booking is completed. This hook currently doesn’t work for Mollie and WooCommerce payments

window.ameliaActions = {
   beforeBooking: function (success = null, error = null, data) {
    console.log('Before booking is created HOOK')
    console.log(data)
    console.log('------------')
    // call success callback for the booking to be completed
    success()
  }
}

On-site booking completed

The hook ‘Schedule’ is triggered after an on-site booking is completed, before the congratulations step is loaded

window.ameliaActions = {
   Schedule: function (success = null, error = null, data) {
     console.log('Schedule HOOK')
     console.log(data)
     console.log('------------')
  }
}

Online booking completed

The hook ‘Purchased’ is triggered after an online booking is completed, before the congratulations step is loaded

window.ameliaActions = {
    Purchased: function (success = null, error = null, data) {
      console.log('Purchased HOOK')
      console.log(data)
      console.log('------------')
  }
}