Notify instructors on new bookings and enrolments
CI / Coding Standards (pull_request) Successful in 27s
CI / Tests (PHP 8.1) (pull_request) Successful in 37s
CI / No Debug Code (pull_request) Successful in 9s
CI / Tests (PHP 8.3) (pull_request) Successful in 36s
CI / Tests (PHP 8.5) (pull_request) Successful in 40s
CI / Tests (PHP 8.2) (pull_request) Successful in 42s
CI / Static Analysis (pull_request) Successful in 48s
CI / Build Plugin Zip (pull_request) Skipped

Add an opt-in, per-instructor email notice sent when someone books one of
their lessons or enrols in one of their group classes. Off by default and
set from My Availability → Notifications; covers both the student/guardian
REST flows and the studio's wp-admin "book/add for a student" forms.

The opt-in check lives in InstructorNotificationMailer so no booking path
can drift on who is mailed; lessons fire from LessonBooker::settle (the one
step both booking paths reach), enrolments from EnrollmentEndpoint::enroll
and GroupClassController::addDirect. The notice is a courtesy and never
fails a booking or enrolment that otherwise succeeded.

Co-authored-by: anthropic/claude-opus-4-8
This commit is contained in:
2026-09-18 16:18:43 -03:00
co-authored by anthropic/claude-opus-4-8
parent 56fc0bd57d
commit 12765d8f13
16 changed files with 583 additions and 3 deletions
+20
View File
@@ -15,6 +15,7 @@ if (! defined('ABSPATH')) {
* @var string $nextWeek
* @var string $notice Success message from the submitted action; empty when none.
* @var string $error Failure message from the submitted action; empty when none.
* @var bool $notifyOnBooking Whether the instructor is emailed on new bookings/enrolments.
*/
use Unsupervised\Schedular\Availability\AvailabilitySlot;
@@ -44,6 +45,25 @@ $deleteForm = static function (\Unsupervised\Schedular\Availability\Availability
<div class="notice notice-error is-dismissible"><p><?php echo esc_html($error); ?></p></div>
<?php endif; ?>
<h2><?php esc_html_e('Notifications', 'unsupervised-schedular'); ?></h2>
<form method="post">
<?php wp_nonce_field('usc_availability_action'); ?>
<input type="hidden" name="usc_action" value="save_notify">
<table class="form-table">
<tr>
<th scope="row"><?php esc_html_e('Booking emails', 'unsupervised-schedular'); ?></th>
<td>
<label>
<input type="checkbox" name="notify_on_booking" value="1" <?php checked($notifyOnBooking); ?>>
<?php esc_html_e('Email me when someone books a lesson or enrols in one of my group classes', 'unsupervised-schedular'); ?>
</label>
<p class="description"><?php esc_html_e('Off by default. Covers both your private lessons and your group classes, whether the student booked themselves or the studio booked for them.', 'unsupervised-schedular'); ?></p>
</td>
</tr>
</table>
<?php submit_button(esc_html__('Save Notification Preference', 'unsupervised-schedular')); ?>
</form>
<h2><?php esc_html_e('Add Availability', 'unsupervised-schedular'); ?></h2>
<p><?php esc_html_e('The window must start and end on the same day. It is split into bookable slots of the chosen lesson length — for example, 9:00 AM4:00 PM with 60-minute lessons creates seven slots.', 'unsupervised-schedular'); ?></p>
<form method="post" id="usc-add-availability">