Make sure the randomly selected provider is really serving the selected service, when generating availability wit the "Any Provider" option in the frontend (#991).

This commit is contained in:
Alex Tselegidis 2021-01-27 13:39:12 +01:00
parent 120421b3af
commit af350fc617
1 changed files with 6 additions and 1 deletions

View File

@ -75,7 +75,12 @@ window.FrontendBookApi = window.FrontendBookApi || {};
var providerId = $('#select-provider').val();
if (providerId === 'any-provider') {
providerId = GlobalVariables.availableProviders[0].id; // Use first available provider.
for (var availableProvider of GlobalVariables.availableProviders) {
if (availableProvider.services.indexOf(serviceId) !== -1) {
providerId = availableProvider.id; // Use first available provider.
break;
}
}
}
var provider = GlobalVariables.availableProviders.find(function (availableProvider) {