You can do that
without code:
Do not click on “Export”, instead
– copy the export url,
– paste it in a new tab of your browser
– add &order_by=event_start at the end of the URL
– Load the page, it will download your csv file
with code:
Add this code in your child theme functions.php:
function my_theme_export_bookings_attributes( $filters ) {
$filters[ 'order_by' ] = array( 'event_start' );
$filters[ 'order' ] = 'desc';
return $filters;
}
add_filter( 'bookacti_export_bookings_attributes', 'my_theme_export_bookings_attributes', 100, 1 );
Note that the whole list will be sorted, so if you want to export bookings only during a specific frame of time, fill the “Date” filter before exporting (no need to apply filters).
You are absolutely amazing, thank you so much this “small” thing has just moved a mountain of a process out of the way for me with a client. May you become so rich you do not know what to do with all the money π
Thanks again.
Works perfectly.
Ah ah! May Santa browse this forum π
Great, thank you for your feedback,
Moreover, in the next version (1.7.12), the exported bookings will keep the current booking list sorting by default, so you will be able to sort them using the UI.
One more thing, is if possible to change the format of the date in the url csv export to say Mon, Tues, Wed? Or change the date format?
The client would basically like the date to be exported to show the name of the DAY of the week. I don’t think that is possible? At least I think the date format can refer to the name of the MONTH such as “30-June 2008” but nit the DAY. Do you agree?
The csv format isn’t meant to be read by humans, that’s why raw data are exported, so you can manipulate them easier later in the app where they are imported (MS Excel, Google Sheets, etc…)
Those apps will be able to read those date, recognize them as such, and automatically convert them in any user-friendly format, because they are in ISO format.
But it is possible by code:
Hook: 'bookacti_booking_export_columns_content' wp-content\plugins\booking-activities\functions line 1206
// Format exported bookings data
function my_theme_format_exported_bookings_data( $booking_item, $booking, $group, $user, $filters, $columns ) {
$booking_item[ 'start_date' ] = bookacti_format_datetime( $booking_item[ 'start_date' ], 'D d-F Y' );
$booking_item[ 'end_date' ] = bookacti_format_datetime( $booking_item[ 'end_date' ], 'D d-F Y' );
return $booking_item;
}
add_filter( 'bookacti_booking_export_columns_content', 'my_theme_format_exported_bookings_data', 100, 6 );
Where ‘D d-F Y’ is the date format (docs).
You really are a genius! thanks. In this particular use case the client is simply using the export url to quickly view an activities bookings for the day on their mobile phone with least hassle, so they arent opening in another program but viewing the CSV straight in their phone browser – > your explanation makes perfect sense.
Last last question promise. On the front end when viewing the calendar in “Week view” the date displays as “Wed 12/11” – this means of course 11th of December but is American format.
I would just like to swap the month and day around so that the 11th of Dec is displayed as “Wed 11/12” instead of “Wed 12/11” – I have tried to change this in the plugin settings as well as wordpress settings but not managed to get it right. Are you able to assist?
-
This reply was modified 6 years, 6 months ago by
pierremare.
You are welcome π
The date format in the calendar is determined by your site locale in Settings > General > “Site language” option.
If you set it to “English (UK)” the date format will be as desired.