Cancellation cutoff: limit how close to a lesson a student can cancel #94
@@ -134,8 +134,8 @@ class StudioSettings {
|
|||||||
$hstRate = $this->hstRate();
|
$hstRate = $this->hstRate();
|
||||||
$stripeConfigured = $this->isStripeConfigured();
|
$stripeConfigured = $this->isStripeConfigured();
|
||||||
$openRegistration = $this->openRegistrationEnabled();
|
$openRegistration = $this->openRegistrationEnabled();
|
||||||
// Stored in hours, surfaced to the admin in days.
|
// Stored in hours, surfaced to the admin in whole days.
|
||||||
$cancellationCutoffDays = $this->cancellationCutoffHours() / 24;
|
$cancellationCutoffDays = (int) round( $this->cancellationCutoffHours() / 24 );
|
||||||
|
|
||||||
include USC_PLUGIN_DIR . 'templates/admin/settings.php';
|
include USC_PLUGIN_DIR . 'templates/admin/settings.php';
|
||||||
}
|
}
|
||||||
@@ -162,10 +162,10 @@ class StudioSettings {
|
|||||||
$hstRate = isset( $_POST['hst_rate'] ) ? Val::float( $_POST['hst_rate'] ) : 0.0;
|
$hstRate = isset( $_POST['hst_rate'] ) ? Val::float( $_POST['hst_rate'] ) : 0.0;
|
||||||
update_option( self::OPT_HST_RATE, max( 0.0, $hstRate ) );
|
update_option( self::OPT_HST_RATE, max( 0.0, $hstRate ) );
|
||||||
|
|
||||||
// The cutoff is entered in days but stored in hours.
|
// The cutoff is entered in whole days but stored in hours.
|
||||||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Val::float() coerces to float; slashes cannot survive numeric coercion.
|
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Val::int() coerces to int; slashes cannot survive numeric coercion.
|
||||||
$cutoffDays = isset( $_POST['cancellation_cutoff_days'] ) ? max( 0.0, Val::float( $_POST['cancellation_cutoff_days'] ) ) : 0.0;
|
$cutoffDays = isset( $_POST['cancellation_cutoff_days'] ) ? max( 0, Val::int( $_POST['cancellation_cutoff_days'] ) ) : 0;
|
||||||
update_option( self::OPT_CANCELLATION_CUTOFF_HOURS, (int) round( $cutoffDays * 24 ) );
|
update_option( self::OPT_CANCELLATION_CUTOFF_HOURS, $cutoffDays * 24 );
|
||||||
|
|
||||||
$this->applyRegistrationMode( isset( $_POST['open_registration'] ) );
|
$this->applyRegistrationMode( isset( $_POST['open_registration'] ) );
|
||||||
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ if (! defined('ABSPATH')) {
|
|||||||
* @var float $hstRate
|
* @var float $hstRate
|
||||||
* @var bool $stripeConfigured
|
* @var bool $stripeConfigured
|
||||||
* @var bool $openRegistration
|
* @var bool $openRegistration
|
||||||
* @var float $cancellationCutoffDays
|
* @var int $cancellationCutoffDays
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
@@ -96,7 +96,7 @@ if (! defined('ABSPATH')) {
|
|||||||
<tr>
|
<tr>
|
||||||
<th><label for="cancellation_cutoff_days"><?php esc_html_e('Cancellation cutoff (days)', 'unsupervised-schedular'); ?></label></th>
|
<th><label for="cancellation_cutoff_days"><?php esc_html_e('Cancellation cutoff (days)', 'unsupervised-schedular'); ?></label></th>
|
||||||
<td>
|
<td>
|
||||||
<input type="number" name="cancellation_cutoff_days" id="cancellation_cutoff_days" class="small-text" min="0" step="0.5" value="<?php echo esc_attr(rtrim(rtrim(number_format($cancellationCutoffDays, 2, '.', ''), '0'), '.')); ?>">
|
<input type="number" name="cancellation_cutoff_days" id="cancellation_cutoff_days" class="small-text" min="0" step="1" value="<?php echo esc_attr((string) $cancellationCutoffDays); ?>">
|
||||||
<p class="description"><?php esc_html_e('How far ahead of a lesson a student may still cancel it. Within this window only an instructor can cancel. 0 lets students cancel any time. An offering can override this with its own value.', 'unsupervised-schedular'); ?></p>
|
<p class="description"><?php esc_html_e('How far ahead of a lesson a student may still cancel it. Within this window only an instructor can cancel. 0 lets students cancel any time. An offering can override this with its own value.', 'unsupervised-schedular'); ?></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user