Documentation
- Getting started
- Basic settings
- Pro settings
- Product settings
- Manage bookings
- Localization
- Snippets
- Action and filter hooks
- Third-party plugins
Export bookings
- (Optional) Use the filters at the top of the page to filter bookings you wish to export and click on “Filter”.
- Select the format you wish to export to (JSON, XML, CSV, iCal).
- Click on “Export” and save the file.
By default, the following data is exported for each booking:
- Product ID
- Start date
- End date
- Quantity
There are filters available for each format in order to customize the exported data (see below).
Customizing exported data
CSV
add_filter( 'easy_booking_csv_export_headers', 'wceb_custom_csv_headers', 10, 1 ); function wceb_custom_csv_headers( $headers ) { $headers = 'product_id, start_date, end_date, quantity'; // Default return $headers; }
add_filter( 'easy_booking_csv_export_line', 'wceb_custom_csv_line', 10, 2 ); function wceb_custom_csv_line( $content, $booking ) { $content = $booking['product_id'] . ',' . $booking['start'] . ',' . $booking['end'] . ',' . $booking['qty']; // Default return $content; }
JSON
add_filter( 'easy_booking_json_export', 'wceb_custom_json', 10, 2 ); function wceb_custom_json( $content, $bookings ) { $content = json_encode( $bookings ); // Default return $content; }
XML
add_filter( 'easy_booking_xml_export_line', 'wceb_custom_xml_line', 10, 2 ); function wceb_custom_xml_line( $content, $booking ) { $content = '<booking product_id="' . $booking['product_id'] . '" start_date="' . $booking['start'] . '" end_date="' . $booking['end'] . '" qty="' . $booking['qty'] . '" />'; // Default return $content; }
iCal
add_filter( 'easy_booking_ical_export_calendar', 'wceb_custom_ical_calendar', 10, 1 ); function wceb_custom_ical_calendar( $content ) { $site_name = get_bloginfo( 'name' ); $timezone = get_option( 'timezone_string' ); $content = 'BEGIN:VCALENDAR PRODID:-//' . $site_name . '//Bookings//EN VERSION:2.0 X-WR-TIMEZONE:' . $timezone; // Default return $content; }
add_filter( 'easy_booking_ical_export_event', 'wceb_custom_ical_event', 10, 2 ); function wceb_custom_ical_event( $content, $booking ) { $content = 'BEGIN:VEVENT DTSTART:' . wceb_get_date_for_ical( strtotime( $booking['start'] ) ) . ' DTEND:' . wceb_get_date_for_ical( strtotime( $booking['end'] ) ) . ' DTSTAMP:' . wceb_get_date_for_ical( time() ) . ' UID:' . $this->generate_uuid() . ' SUMMARY: #' . $booking['product_id'] . ' END:VEVENT'; // default return $content; }