From af350fc617da0d3fe2f50ceb176d42c296452525 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 27 Jan 2021 13:39:12 +0100 Subject: [PATCH] Make sure the randomly selected provider is really serving the selected service, when generating availability wit the "Any Provider" option in the frontend (#991). --- assets/js/frontend_book_api.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/js/frontend_book_api.js b/assets/js/frontend_book_api.js index d5330352..68c708e4 100755 --- a/assets/js/frontend_book_api.js +++ b/assets/js/frontend_book_api.js @@ -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) {