When using the filter "amelia_before_get_timeslots_filter" to change the amount of persons in a service, it's sending the persons parameters as 1 during the ajax call on the 2.0 form.
If personsCount is updated to 2, i would expect the ajax call to be updated also.
This is a service that is mandatory to come with someone (min capacity 2, max capacity 2), And its important because it will use 2 resources. If the client forgets to add that he is comming with someone, other slots won't be blocked accordingly.
So i need a way to make this service always bring someone, without the user having to input manually.
As the filter you sent is only for calculating slots, if you want your booking to be for 2 persons as well, you'll need to add a booking filter for it too, something like this:
function amelia_before_get_timeslots_filter($props) { if ($props['serviceId'] === 12) { $props['personsCount'] = 2; $props['totalPersons'] = 2; } return $props; }
The AJAX call remains unchanged because this filter is applied on the backend. Even if you send persons=1, it will be adjusted in PHP.
We’ve tested the filter on our end, and it seems to be working as expected. After adding it, we noticed that the timeslots differ from those we previously had. If it's not working on your side, could you please share a short video explaining the issue? This will help us understand the situation better and assist you more effectively.
When using the filter "amelia_before_get_timeslots_filter" to change the amount of persons in a service, it's sending the persons parameters as 1 during the ajax call on the 2.0 form.
https://thefloat.com.py/wp-admin/admin-ajax.php?action=wpamelia_api&call=/slots&queryTimeZone=America%2FAsuncion&monthsLoad=1&locationId=1&serviceId=12&serviceDuration=5400&providerIds=35,36,37,38,39,77&group=1&page=booking&persons=1
function amelia_before_get_timeslots_filter($props)
{
if ($props['serviceId'] === 12) {
$props['personsCount'] = 2;
}
return $props;
}
add_filter('amelia_before_get_timeslots_filter', 'amelia_before_get_timeslots_filter', 0, 1);
If personsCount is updated to 2, i would expect the ajax call to be updated also.
This is a service that is mandatory to come with someone (min capacity 2, max capacity 2), And its important because it will use 2 resources. If the client forgets to add that he is comming with someone, other slots won't be blocked accordingly.
So i need a way to make this service always bring someone, without the user having to input manually.
Hi Ricardo,
As the filter you sent is only for calculating slots, if you want your booking to be for 2 persons as well, you'll need to add a booking filter for it too, something like this:
function amelia_before_get_timeslots_filter($props)
{
if ($props['serviceId'] === 12) {
$props['personsCount'] = 2;
$props['totalPersons'] = 2;
}
return $props;
}
add_filter('amelia_before_get_timeslots_filter', 'amelia_before_get_timeslots_filter', 0, 1);
function amelia_before_booking($props)
{
if ($props['serviceId'] === 12) {
$props['bookings'][0]['persons'] = 2;
}
return $props;
}
add_filter('amelia_before_booking_added_filter', 'amelia_before_booking', 0, 1);
Kind Regards,
Stefan Petrov
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
But its calculating the slots wrong!
I have the other filters and that's working
function amelia_before_appointment_added_filter($appointment, $service, $paymentData)
{
if ($appointment['serviceId'] === 12) { // Ambas flotaciones
$appointment['bookings'][0]['persons'] = 2;
}
return $appointment;
}
add_filter('amelia_before_appointment_added_filter', 'amelia_before_appointment_added_filter', 10, 3);
function amelia_before_booking_added_filter($appointment)
{
if ($appointment['serviceId'] === 12) { // Ambas flotaciones
$appointment['bookings'][0]['persons'] = 2;
}
return $appointment;
}
add_filter('amelia_before_booking_added_filter', 'amelia_before_booking_added_filter', 10, 1);
function amelia_before_get_timeslots_filter($props)
{
if ($props['serviceId'] === 12) {
$props['personsCount'] = 2;
}
return $props;
}
add_filter('amelia_before_get_timeslots_filter', 'amelia_before_get_timeslots_filter', 0, 1);
Its calculating the slots as if I only need 1 resource, but i do need 2.
Even when setting
$props['personsCount'] = 2;
$props['totalPersons'] = 2;
It makes an ajax call and asks for only 1 person
https://thefloat.com.py/wp-admin/admin-ajax.php?action=wpamelia_api&call=/slots&queryTimeZone=America%2FAsuncion&monthsLoad=1&locationId=1&serviceId=12&serviceDuration=5400&providerIds=35,36,37,38,39,77&group=1&page=booking&persons=1
Hello Ricardo,
The AJAX call remains unchanged because this filter is applied on the backend. Even if you send persons=1, it will be adjusted in PHP.
We’ve tested the filter on our end, and it seems to be working as expected. After adding it, we noticed that the timeslots differ from those we previously had. If it's not working on your side, could you please share a short video explaining the issue? This will help us understand the situation better and assist you more effectively.
Kind Regards,
Stefan Petrov
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables