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

View file

@ -75,7 +75,12 @@ window.FrontendBookApi = window.FrontendBookApi || {};
var providerId = $('#select-provider').val(); var providerId = $('#select-provider').val();
if (providerId === 'any-provider') { 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) { var provider = GlobalVariables.availableProviders.find(function (availableProvider) {