Skip to content

Commit 66b3dc5

Browse files
author
Chris Gårdenberg
committed
feat(Booking form): Setting to always allow changing which event the end user wants to attend/book.
fixes #300
1 parent 4bf95fa commit 66b3dc5

5 files changed

Lines changed: 29 additions & 10 deletions

File tree

PLUGIN-CHECKSUM

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a5f3e819cdf5d99c5fdb02f405a1ce34
1+
f627a00988b134b376779c416c52ca3a

content/template/bookingTemplate/course-info.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
$noAvailableDates = false;
2424
$GLOBALS['noAvailableDates'] = false;
2525

26-
if ( ! $selected_course || ! isset( $selected_course['Events'] ) || empty( $selected_course['Events'] ) ) {
26+
if ( ! $selected_course || empty( $selected_course['Events'] ) ) {
2727
$noAvailableDates = true;
2828
$GLOBALS['noAvailableDates'] = true;
2929
}
@@ -41,15 +41,19 @@
4141

4242
$events = $filtered_events;
4343

44+
$always_allow_change_event = EDU()->is_checked( 'eduadmin-alwaysAllowChangeEvent', false );
45+
4446
if ( ! $noAvailableDates ) {
4547
$event = $events[0];
4648
if ( isset( $_GET['eid'] ) && is_numeric( $_GET['eid'] ) ) {
4749
$eventid = intval( $_GET['eid'] );
4850
foreach ( $events as $ev ) {
4951
if ( $eventid === $ev['EventId'] && $ev['StartDate'] > date( "Y-m-d H:i:s" ) ) {
50-
$event = $ev;
51-
$events = array();
52-
$events[] = $ev;
52+
$event = $ev;
53+
if ( ! $always_allow_change_event ) {
54+
$events = array();
55+
$events[] = $ev;
56+
}
5357
break;
5458
}
5559
}
@@ -61,7 +65,7 @@
6165

6266
$questions = EDU()->get_transient( 'eduadmin-event_questions', function() use ( $event_id ) {
6367
return EDUAPI()->REST->Event->BookingQuestions( $event_id, true );
64-
}, DAY_IN_SECONDS, $event_id );
68+
}, DAY_IN_SECONDS, $event_id );
6569

6670
$booking_questions = $questions['BookingQuestions'];
6771
$participant_questions = $questions['ParticipantQuestions'];

content/template/bookingTemplate/event-selector.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
global $events;
3+
global $event;
4+
25
$event_detail_setting = EDU()->get_option( 'eduadmin-date-eventDates-detail', 'default' );
36
$use_short = false;
47
$show_names = false;

includes/booking-settings.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ class="non-eduform-options"<?php echo( ! EDU()->is_checked( 'eduadmin-useBooking
4545

4646
$level_stack = array();
4747
foreach ( $cg['value'] as $g ) {
48-
$level_stack[ (string)$g['ParentCustomerGroupId'] ][] = $g;
48+
$level_stack[ (string) $g['ParentCustomerGroupId'] ][] = $g;
4949
}
5050

5151
$depth = 0;
5252

5353
function edu_write_options( $g, $array, $depth, $selected_option ) {
54-
echo '<option value="' . esc_attr( $g['CustomerGroupId'] ) . '"' . ( $selected_option === (string)$g['CustomerGroupId'] ? ' selected="selected"' : '' ) . '>' .
54+
echo '<option value="' . esc_attr( $g['CustomerGroupId'] ) . '"' . ( $selected_option === (string) $g['CustomerGroupId'] ? ' selected="selected"' : '' ) . '>' .
5555
str_repeat( '&nbsp;', $depth * 4 ) .
5656
esc_html( wp_strip_all_tags( $g['CustomerGroupName'] ) ) .
5757
"</option>\n";
58-
if ( array_key_exists( (string)$g['CustomerGroupId'], $array ) ) {
58+
if ( array_key_exists( (string) $g['CustomerGroupId'], $array ) ) {
5959
$depth++;
60-
foreach ( $array[ (string)$g['CustomerGroupId'] ] as $ng ) {
60+
foreach ( $array[ (string) $g['CustomerGroupId'] ] as $ng ) {
6161
edu_write_options( $ng, $array, $depth, $selected_option );
6262
}
6363
$depth--;
@@ -136,6 +136,15 @@ class="eduadmin-forceLogin"<?php echo( EDU()->is_checked( 'eduadmin-useLogin', f
136136
<?php echo esc_html_x( 'Allow end customer to overwrite customer info (requires logged in users)', 'backend', 'eduadmin-booking' ); ?>
137137
</label>
138138
<br /><?php
139+
$alwaysAllowChangeEvent = get_option( 'eduadmin-alwaysAllowChangeEvent', false );
140+
?>
141+
<label>
142+
<input type="checkbox"
143+
name="eduadmin-alwaysAllowChangeEvent"<?php checked( $alwaysAllowChangeEvent, "true" ); ?>
144+
value="true" />
145+
<?php echo esc_html_x( 'Allow end customers to always switch between available events', 'backend', 'eduadmin-booking' ); ?>
146+
</label>
147+
<br /> <?php
139148
$allowDiscountCode = get_option( 'eduadmin-allowDiscountCode', false );
140149
?>
141150
<label>

includes/edu-options.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function edu_set_canonical_url( $canonical_url ) {
6868

6969
EDU()->stop_timer( $t );
7070
}
71+
7172
add_filter( 'get_canonical_url', 'edu_set_canonical_url' );
7273

7374
function edu_no_index() {
@@ -198,6 +199,8 @@ function eduadmin_settings_init() {
198199
register_setting( 'eduadmin-booking', 'eduadmin-confirmationSettings-customer' );
199200
register_setting( 'eduadmin-booking', 'eduadmin-confirmationSettings-customercontact' );
200201

202+
register_setting( 'eduadmin-booking', 'eduadmin-alwaysAllowChangeEvent' );
203+
201204
/* Style settings */
202205
register_setting( 'eduadmin-style', 'eduadmin-style' );
203206

0 commit comments

Comments
 (0)