-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
Issue Summary
When using the “Redirect on booking” option with forwarded parameters enabled and embedding the booking widget as a popup, the redirected URL includes not only the booking-related parameters, but also additional popup-specific parameters such as embed, layout, embedType, and overlayCalendar.
In my case, this caused the forwarded page to not load properly when using the latest version of WordPress. Independent of my case, I believe this might cause problems not only with WordPress. I believe the forwarded parameter should not include the popup-specific parameter to ensure the page that the user is forwarded to loads properly.
Steps to Reproduce
- Enable redirect on booking
- Enable forward parameters
- Embed the booking form as a pop-up
Technical details
To solve the problem, I used a custom JavaScript, which "cleaned" the URL. However, this should not be necessary.
Attached is the JavaScript that solved the forwarding of the unwanted parameters:
<script>
document.addEventListener("DOMContentLoaded", function () {
// 1. Parse the current URL's search parameters.
const searchParams = new URLSearchParams(window.location.search);
// 2. Define the list of parameters you want to remove.
const paramsToRemove = ["embed", "layout", "embedType", "overlayCalendar"];
let changed = false;
// 3. Loop through the list and delete each parameter if it exists.
paramsToRemove.forEach(param => {
if (searchParams.has(param)) {
searchParams.delete(param);
changed = true;
}
});
// 4. If any parameters were removed, update the URL in the browser's address bar.
if (changed) {
const newSearch = searchParams.toString();
// Rebuild the URL, preserving the path and hash (#), and adding the new query string.
const newUrl = `${window.location.pathname}${newSearch ? '?' + newSearch : ''}${window.location.hash}`;
window.history.replaceState(null, '', newUrl);
}
});
</script>