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.

Command icon 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:

Comments

hewi1345 created an issue. See original summary.

Sajara’s picture

This feature is of very high importancy for me, too (busyness use). please put an eye on it.

ressa’s picture

@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:

Supporting organizations
mondwiese.de and @Sajara funded development of Booking cancellations.

For an example, see under "Supporting organizations" at https://www.drupal.org/project/search_api_autocomplete/.

rfmarcelino’s picture

Dear @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.

electric.larry’s picture

Version: 1.0.x-dev » 1.1.x-dev
electric.larry’s picture

Now, 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?

electric.larry’s picture

Assigned: Unassigned » electric.larry

electric.larry’s picture

This 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. Replace element_key with the machine name of the Webform Booking field. In this example my form has two Webform Booking fields named appointment_booking and appointment_2.

Confirmation page source

Confirmation page

Confirmation page display

Confirmation page

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.

Cancel booking dialog.

electric.larry’s picture

The 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.

rfmarcelino’s picture

Status: Needs review » Fixed

Thank you @electric.larry, for your contributions!
Committed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.