Bookline documentation1.x
Developers

Hooks and the REST API

The actions, filters and REST endpoints for extending Bookline.

Bookline Pro is built entirely on these hooks, so they're stable.

Loading

bookline_loaded fires once Bookline has loaded (on plugins_loaded). Start add-ons there; the Extendiment\Bookline\* classes and BOOKLINE_* constants are available.

Bookings

add_action( 'bookline_booking_created', function ( $booking, $data ) {
	// $booking is an Extendiment\Bookline\Booking: ->id, ->start, ->end, ->email, ->status…
}, 10, 2 );
Hook When
bookline_booking_created ($booking, $data) A booking was made.
bookline_booking_status_changed ($booking, $old_status, $by) Its status changed; $by is customer, admin or system.
bookline_booking_rescheduled ($booking, $before, $by) It moved.
bookline_booking_updated ($booking, $before) Its details changed.
bookline_booking_delete ($booking) It's about to be deleted.
bookline_booking_anonymised ($booking) Its personal data was erased.

Filters: bookline_validate_booking (return a WP_Error to refuse a booking), bookline_initial_status, bookline_statuses (add a status), bookline_freeing_statuses, bookline_changeable_statuses, bookline_booking_details (rows shown in emails and on pages), bookline_booking_public.

Availability

Filter Use
bookline_busy_times ($busy, $staff, $from, $to) Add busy periods, e.g. from another calendar: return [ [ $start, $end ], … ] timestamps.
bookline_slots ($slots, $service, $date, $args) Change a day's slots.
bookline_slot_interval Minutes between start times for a service.
bookline_service_staff, bookline_schedule, bookline_busy_staff, bookline_parallel_services, bookline_pick_staff Staff members with their own schedules (Bookline Pro).

The form

  • bookline_form_steps adds steps; print a step on bookline_form_step_{key}.
  • bookline_form_details_fields prints more fields in "Your details". Inputs with data-bookline-field="key" are sent along as fields[key], and reach bookline_validate_booking and bookline_booking_created in $data['params']['fields'].
  • bookline_form_config adds data for the form's script.
  • bookline_booking_response: the answer to a new booking. Add redirect to send the customer to another page (for example to pay), or error to show a message.
  • bookline_booking_paid ($paid, $booking): whether a booking was paid for online, so the customer's booking page confirms the payment after ?bookline_done=paid.

The form's script has wp.hooks too: bookline.form.init, bookline.form.step, bookline.form.skip, bookline.form.validate, bookline.availability.params, bookline.booking.payload, bookline.summary.rows and bookline.booked.

Emails

bookline_emails adds an email (editable on the Emails tab); send it with Extendiment\Bookline\Emails::send( $key, $booking ). Also bookline_send_email, bookline_email_recipients, bookline_email_attachments, bookline_email_placeholders and bookline_ics_event.

Admin screens

bookline_admin_menu, bookline_settings_tabs with bookline_settings_tab_{key}, bookline_service_fields and bookline_save_service, bookline_booking_screen_fields, bookline_booking_screen_main, bookline_booking_screen_side, bookline_bookings_columns, bookline_calendar_filters, and who sees what: bookline_can_view_bookings, bookline_bookings_query_args, bookline_edit_booking_caps.

REST API

Namespace bookline/v1:

Endpoint
GET services Bookable services.
GET availability/days?service=&month=YYYY-MM&seats= Each day of a month: open, full or closed.
GET availability/slots?service=&date=YYYY-MM-DD&seats= The day's time slots.
POST bookings Make a booking (service, start timestamp, seats, name, email, phone, notes, and the nonce from an availability answer).
GET bookings/{key}, POST bookings/{key}/cancel, POST bookings/{key}/reschedule A customer's booking, by its key.
GET bookings?from=&to= Bookings, for people who can view them.

Other filters

bookline_now (the current time, for tests), bookline_lock_timeout, bookline_client_ip (behind a proxy), bookline_format_price.