Apply the worker capability filter to the manage-booking flow

The per-worker service allow-list was only enforced on the new-booking form.
On the guest manage-booking page a worker could still be offered for services
they do not perform:

- manage_booking() branched on $firstService, which was never assigned - the
  resolve loop above it used $resolvedService - so the guarded branch was dead
  and the worker list fell through to getActiveWorkers(), filtered by vertical
  only. Assigning it activates both the category filter and the capability
  check, and with it the $isOtherCategory checkbox disabling in the view.
- The page's own getAvailableWorkersByServiceCategorySlug() never sent
  service_ids, so re-picking services asked for a category-only worker list.
  It now mirrors the booking form, including the empty-result message.
- setWorker() clears any time already chosen: changing worker or services left
  a stale selection with the submit button still enabled.

manage_booking_process() did re-check capability server-side, but every
rejection there answered with raw JSON, which this non-AJAX form renders as an
unstyled blob in the guest's browser. All eight rejections, plus the
cancellation cutoff, now go through _booking_error(), which takes an optional
back URL so the guest returns to their own manage page rather than an empty
booking form. Adds the cutoff_passed message in all three languages and makes
the error title and button label reflect which flow failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TYGSbK1erKv7VG1pvdPEjG
This commit is contained in:
Ubuntu
2026-08-24 17:06:08 +00:00
co-authored by Claude Opus 5
parent 13e1b1a672
commit ce7400578a
5 changed files with 103 additions and 34 deletions
@@ -10,6 +10,7 @@
'service_not_offered' => 'The selected staff member does not perform all of the chosen treatments. Please pick another staff member or change the treatments.',
'single_service_only' => 'Only one treatment can be booked at a time. Please select just one.',
'invalid_email' => 'That e-mail address does not look valid. Please check it - your confirmation and the link to manage your booking are sent there.',
'cutoff_passed' => 'Your booking is within 24 hours and can no longer be changed or cancelled. Please contact the salon.',
'no_service' => 'No service was selected. Please choose at least one service.',
'default' => 'Something went wrong with your booking. Please try again.',
);
@@ -19,12 +20,24 @@
: $bookingErrorMessages['default'];
$backSubpage = isset($subpage) && $subpage != '' ? $subpage : 'barber';
$backUrl = SITEURL.'en/booking/'.$backSubpage;
// _booking_error() passes a back URL when the error came from the
// manage-booking flow; that guest must return to their own booking page
// rather than being dropped into an empty new-booking form.
$isManageError = isset($bookingBackUrl) && $bookingBackUrl !== '';
$backUrl = $isManageError ? $bookingBackUrl : SITEURL.'en/booking/'.$backSubpage;
$backLabel = $isManageError ? 'Back to your booking' : 'Back to booking';
if(isset($bookingErrorCode) && $bookingErrorCode === 'slot_taken'){
$errorTitle = 'This time is no longer available';
} else {
$errorTitle = $isManageError ? 'Your booking could not be changed' : 'Your booking could not be completed';
}
?>
<div class="bookingContainer" style="min-height:500px;">
<div class="bookingThankYouTitle">This time is no longer available</div>
<div class="bookingThankYouTitle"><?php echo $errorTitle;?></div>
<div class="bookingThankYouMessageTitle"><?php echo $shownError;?></div>
<div style="text-align:center; margin-top:30px;">
<a href="<?php echo $backUrl;?>" style="display:inline-block; padding:12px 28px; background:#000; color:#fff; text-decoration:none; border-radius:5px; font-size:16px;">Back to booking</a>
<a href="<?php echo $backUrl;?>" style="display:inline-block; padding:12px 28px; background:#000; color:#fff; text-decoration:none; border-radius:5px; font-size:16px;"><?php echo $backLabel;?></a>
</div>
</div>
@@ -10,6 +10,7 @@
'service_not_offered' => 'A kiválasztott kolléga nem végzi el az összes kiválasztott szolgáltatást. Kérjük, válasszon másik kollégát, vagy módosítsa a szolgáltatásokat.',
'single_service_only' => 'Egyszerre csak egy kezelés foglalható. Kérjük, csak egyet válasszon.',
'invalid_email' => 'Az e-mail cím nem tűnik érvényesnek. Kérjük, ellenőrizze - a visszaigazolást és a foglalás kezelésére szolgáló linket erre a címre küldjük.',
'cutoff_passed' => 'A foglalás 24 órán belül van, ezért már nem módosítható és nem törölhető. Kérjük, vedd fel a kapcsolatot a szalonnal.',
'no_service' => 'Nem választott ki szolgáltatást. Kérjük, válasszon legalább egyet.',
'default' => 'Hiba történt a foglalás során. Kérjük, próbálja újra.',
);
@@ -19,12 +20,24 @@
: $bookingErrorMessages['default'];
$backSubpage = isset($subpage) && $subpage != '' ? $subpage : 'barber';
$backUrl = SITEURL.'hu/booking/'.$backSubpage;
// _booking_error() passes a back URL when the error came from the
// manage-booking flow; that guest must return to their own booking page
// rather than being dropped into an empty new-booking form.
$isManageError = isset($bookingBackUrl) && $bookingBackUrl !== '';
$backUrl = $isManageError ? $bookingBackUrl : SITEURL.'hu/booking/'.$backSubpage;
$backLabel = $isManageError ? 'Vissza a foglalásodhoz' : 'Vissza a foglaláshoz';
if(isset($bookingErrorCode) && $bookingErrorCode === 'slot_taken'){
$errorTitle = 'Ez az időpont már nem foglalható';
} else {
$errorTitle = $isManageError ? 'A foglalást nem sikerült módosítani' : 'A foglalást nem sikerült véglegesíteni';
}
?>
<div class="bookingContainer" style="min-height:500px;">
<div class="bookingThankYouTitle">Ez az időpont már nem foglalható</div>
<div class="bookingThankYouTitle"><?php echo $errorTitle;?></div>
<div class="bookingThankYouMessageTitle"><?php echo $shownError;?></div>
<div style="text-align:center; margin-top:30px;">
<a href="<?php echo $backUrl;?>" style="display:inline-block; padding:12px 28px; background:#000; color:#fff; text-decoration:none; border-radius:5px; font-size:16px;">Vissza a foglaláshoz</a>
<a href="<?php echo $backUrl;?>" style="display:inline-block; padding:12px 28px; background:#000; color:#fff; text-decoration:none; border-radius:5px; font-size:16px;"><?php echo $backLabel;?></a>
</div>
</div>
@@ -10,6 +10,7 @@
'service_not_offered' => 'Den valgte medarbeideren utfører ikke alle de valgte behandlingene. Vennligst velg en annen medarbeider eller endre behandlingene.',
'single_service_only' => 'Du kan kun bestille én behandling om gangen. Vennligst velg kun én.',
'invalid_email' => 'E-postadressen ser ikke ut til å være gyldig. Vennligst kontroller den - bekreftelsen og lenken for å endre bestillingen sendes dit.',
'cutoff_passed' => 'Bestillingen er innen 24 timer og kan ikke lenger endres eller avbestilles. Vennligst ta kontakt med salongen.',
'no_service' => 'Du har ikke valgt noen tjeneste. Vennligst velg minst én tjeneste.',
'default' => 'Noe gikk galt med bestillingen. Vennligst prøv igjen.',
);
@@ -19,12 +20,24 @@
: $bookingErrorMessages['default'];
$backSubpage = isset($subpage) && $subpage != '' ? $subpage : 'barber';
$backUrl = SITEURL.'no/booking/'.$backSubpage;
// _booking_error() passes a back URL when the error came from the
// manage-booking flow; that guest must return to their own booking page
// rather than being dropped into an empty new-booking form.
$isManageError = isset($bookingBackUrl) && $bookingBackUrl !== '';
$backUrl = $isManageError ? $bookingBackUrl : SITEURL.'no/booking/'.$backSubpage;
$backLabel = $isManageError ? 'Tilbake til bestillingen din' : 'Tilbake til bestilling';
if(isset($bookingErrorCode) && $bookingErrorCode === 'slot_taken'){
$errorTitle = 'Tidspunktet er ikke lenger tilgjengelig';
} else {
$errorTitle = $isManageError ? 'Bestillingen kunne ikke endres' : 'Bestillingen kunne ikke fullføres';
}
?>
<div class="bookingContainer" style="min-height:500px;">
<div class="bookingThankYouTitle">Tidspunktet er ikke lenger tilgjengelig</div>
<div class="bookingThankYouTitle"><?php echo $errorTitle;?></div>
<div class="bookingThankYouMessageTitle"><?php echo $shownError;?></div>
<div style="text-align:center; margin-top:30px;">
<a href="<?php echo $backUrl;?>" style="display:inline-block; padding:12px 28px; background:#000; color:#fff; text-decoration:none; border-radius:5px; font-size:16px;">Tilbake til bestilling</a>
<a href="<?php echo $backUrl;?>" style="display:inline-block; padding:12px 28px; background:#000; color:#fff; text-decoration:none; border-radius:5px; font-size:16px;"><?php echo $backLabel;?></a>
</div>
</div>