Hello,
Yes, it’s possible thanks to Booking Activities API.
Add this code to your child theme functions.php:
/**
* Display only users who have made a booking on specific calendars in booking list user selectbox filter
* @param array $args
* @return array
*/
function my_theme_booking_list_user_selectbox( $args ) {
$filters = bookacti_format_booking_filters( array() );
$bookings = bookacti_get_bookings( $filters );
$user_ids = array();
foreach( $bookings as $booking ) {
if( ! in_array( $booking->user_id, $user_ids, true ) ){
$user_ids[] = $booking->user_id;
}
}
$args[ 'include' ] = $user_ids;
return $args;
}
add_filter( 'bookacti_booking_list_user_selectbox_args', 'my_theme_booking_list_user_selectbox', 10, 1 );
Note that this code get the customers who have made a booking on any of the calendars managed by the current user.
If you want to display only customers of the selected calendar(s) in the filters, replace
$filters = bookacti_format_booking_filters( array() );
with
$filters = bookacti_format_booking_filters( array( 'templates' => isset( $_REQUEST[ 'templates' ] ) ? $_REQUEST[ 'templates' ] : array() ) );
Regards,
Yoan Cutillas
That works! Thank you very much for the fast reply.
Is there any documentation of the Booking Activities API?
Best,
Steffen
You are welcome!
I just noticed that
$filters = bookacti_format_booking_filters( array() );
should be
$filters = bookacti_format_booking_filters( array( 'templates' => array() ) );
in order to use only the calendars allowed by the current user. Else, it uses all the calendars regardless of permission, which is pointless in that case.
I guess you used the second solution (taking $_REQUEST[ 'templates' ] into account) which is working fine π
There is no API documentation yet. Booking Actvities is changing rapidly, it would take too much time to do it now.
For now, you have to browse the code to find what you need. But it’s actually a great way to learn how Booking Activities works and then make your custom code maintenance easier.
Regards,
Yoan Cutillas
I have a further question regarding bookings section on the dashboard. Is it possible to customize the design of the calendar editor and the bookings? Because we allow several users to manage their own booking calendar on our website and they perhaps want to change design. For example to change the selection from the accessible calendars from a dropdown menu to a radio button list?
Thanks in advance.
Hello,
You can change the design with CSS for sure, but replacing a HTML element with an other (like a selectbox to radio buttons) is more complicated. In such cases, you can do what the API allow you to do. I just checked the code and you cannot do this specific change, sorry.
Regards,
Yoan Cutillas
Hey,
we just bought the Order for Customers add-on of your plugin.
There we also want to filter the customers who have made a booking on any of the calendars managed by the current user.
Can we also do this with your API?
Thanks in advance.
Another question regarding the Order for Customers add-on:
We allow several users to manage their own booking calendar on our website. For these users we created a new user role where we assign the proper permissions to use the booking activities tool.
The Order for Customers add-on allows only administrator to order for an existing user/customer. Can we also allow our new user role to use this feature?
Thanks
Hello,
Thank you very much for your purchase.
However, wordpress.org doesn’t allow to discuss about paid add-ons on their forums, please contact me by email for any question about them next time.
1. You can’t for bookings made with a booking form generated from the shortcode. But it would be possible for bookings made with WooCommerce since the operator ID is stored as the _operator_id order meta.
2. Order for Customers also features it own role: Operators. Administrators and Operators are allowed to order for a customers by default. You can grant any user the permission to order for a customer: use a plugin such as “User role editor”, and grant the desired user (or the desired role) the permission called “order_for_customers”.
Regards,
Yoan Cutillas