Problem/Motivation
When someone makes a booking, it happens from time to time that customers want to cancel it.
By implementing the following process, we would simplify booking cancellations, reduce manual intervention, and empower users to manage their reservations efficiently.
Proposed resolution
When a user makes a booking, the system automatically generates a simple unique hash.
This hash is associated with the booking details (e.g., submission ID, date, etc.).
Sending a Confirmation Email:
After a successful booking, the module sends the user a confirmation email.
The email includes the unique hash as part of the cancellation link.
Cancellation Process:
When a user wants to cancel their booking, they click on the cancellation link.
The link directs them to a specific URL (e.g., https://yourwebsite.com/cancel?hash=unique_hash).
Module Handling:
Upon accessing the cancellation link, a function extracts the hash from the URL and looks up the booking associated with that hash.
Relevant information (such as booking details) is displayed to the user.
A confirmation button for cancellation is provided.
Email Notification:
The system sends an email to the user to confirm the cancellation.
In this email, we need a link with a more complex Hash (e.g., using a secure hashing algorithm like SHA-256) This Link should have an expiration time for added security as well.
Cancellation Confirmation:
If the user confirms the cancellation, we mark or delete the booking from the submissions.
The booking slot becomes available for others to use.
Issue fork webform_booking-3450608
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3450608-booking-cancellations
changes, plain diff MR !13 /
changes, plain diff MR !10
Comments
Comment #2
Sajara commentedThis feature is of very high importancy for me, too (busyness use). please put an eye on it.
Comment #3
ressa@Sajara: Remember that Drupal is open source, and run by volunteers, offering their time and services for free.
You and @hewi1345 could consider sponsoring @rfmarcelino to build this feature?
Then, perhaps, you could get mentioned on the project page, like this:
For an example, see under "Supporting organizations" at https://www.drupal.org/project/search_api_autocomplete/.
Comment #4
rfmarcelino commentedDear @hewi1345 @Sajara
Thank you for your feedback.
There are several implications to consider.
The email content usually needs to be customised and a generic solution may not work well for most use cases.
The simplest approach, since Webform already allows to configure emails, would be to provide a token for the cancellation URL.
That would allow to embed inside a custom confirmation email.
A controller would get that cancellation request and remove the value from the submission.
Currently, the cancellation is deleting the field content. In terms of auditing, it's not great. It would be probably better to have a hidden 'Canceled' status.
As @ressa just mentioned, we are volunteering our time. We have a set weekly contribution hours. If you need a specific feature within a specific timeframe, feel free to reach us.
Comment #5
electric.larry commentedComment #6
electric.larry commentedNow, as we introduced tokens in webform_booking 1.1.4 and submission objects can already create hashes (?token=****) that allow for viewing/updating/deleting submissions, we basically have all we need for the cancellation feature.
@rfmarcelino: In #4, you said: "Currently, the cancellation is deleting the field content.
Is there some cancellation feature in webform_booking already, or are you referring to the built-in functions for editing/updating submissions (webform_submission:token-delete-url, webform_submission:token-update-url)?
Also, in #4, you said: "In terms of auditing, it's not great. It would be probably better to have a hidden 'Canceled' status."
I'm wondering how you'd prefer approaching this. In webform_submission_data, we're saving a value like "2025-01-07 09:00|1" for one booked slot on the 7th. Would you rather just update the value to "2025-01-07 09:00|0" when a user clicks the cancel link, or do you think it would be better to change the value to something like "2025-01-07 09:00|1|cancelled"? Or did you have something completely different in mind for the hidden canceled status?
Comment #7
electric.larry commentedComment #9
electric.larry commentedThis patch adds the requested cancellation feature.
A new token is available
[webform_submission:booking:element_key:cancel_link]that can be placed on the confirmation page or popup. Replaceelement_keywith the machine name of the Webform Booking field. In this example my form has two Webform Booking fields namedappointment_bookingandappointment_2.Confirmation page source
Confirmation page display
If you have more than one Webform Booking fields on your form, only place one cancel link on the cofirmation page. Opening the link displays a list of all Webform Booking fields in that submission and allows the user to select the bookings he wants to cancel.
Comment #10
electric.larry commentedThe patch in #9 also fixes another issue with creation of tokens if multiple Webform Booking fields are placed on a form and one of them is submitted empty.
Comment #14
rfmarcelino commentedThank you @electric.larry, for your contributions!
Committed!