From 5283d7f1ab8d4fcd859268f84499f3a8d1f704fb Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Wed, 27 Dec 2023 14:46:29 -0600 Subject: [PATCH] Add default model setting --- src/mt-processing.php | 4 ++++ src/mt-ticketing-settings.php | 26 ++++++++++++++++++-------- src/my-tickets.php | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/mt-processing.php b/src/mt-processing.php index 1574b1d6..c8b640cf 100644 --- a/src/mt-processing.php +++ b/src/mt-processing.php @@ -282,6 +282,10 @@ function mt_registration_fields( $form, $has_data, $data, $public = 'admin' ) { $checked = ( 'true' === get_post_meta( $event_id, '_mt_sell_tickets', true ) ) ? ' checked="checked"' : ''; $notes = get_post_meta( $event_id, '_mt_event_notes', true ); } + if ( empty( $registration ) ) { + $default_model = $options['default_model']; + $registration = $options['defaults'][ $default_model ]; + } $expiration = ( isset( $registration['reg_expires'] ) ) ? $registration['reg_expires'] : $options['defaults']['reg_expires']; $multiple = ( isset( $registration['multiple'] ) ) ? $registration['multiple'] : $options['defaults']['multiple']; $is_multiple = ( 'true' === $multiple ) ? 'checked="checked"' : ''; diff --git a/src/mt-ticketing-settings.php b/src/mt-ticketing-settings.php index a87c0142..5c366ea5 100644 --- a/src/mt-ticketing-settings.php +++ b/src/mt-ticketing-settings.php @@ -42,20 +42,21 @@ function mt_update_ticketing_settings( $post ) { $close_type = ( isset( $post['mt_tickets_close_type'] ) ) ? $post['mt_tickets_close_type'] : 'integer'; $mt_display_remaining = ( isset( $post['mt_display_remaining'] ) ) ? $post['mt_display_remaining'] : 'proportion'; $mt_ticket_image = ( isset( $post['mt_ticket_image'] ) ) ? $post['mt_ticket_image'] : 'ticket'; + $default_model = ( isset( $post['default_model'] ) ) ? $post['default_model'] : 'continuous'; $ticket_models = array( 'continuous', 'discrete', 'event' ); foreach ( $ticket_models as $model ) { - $model_defaults = ( isset( $post['defaults'][ $model ] ) ) ? $post['defaults'][ $model ] : array(); - $labels = ( isset( $post['mt_label'][ $model ] ) ) ? $post['mt_label'][ $model ] : array(); - $prices = ( isset( $post['mt_price'][ $model ] ) ) ? $post['mt_price'][ $model ] : array(); - $close = ( isset( $post['mt_close'][ $model ] ) ) ? $post['mt_close'][ $model ] : array(); - $availability = ( isset( $post['mt_tickets'][ $model ] ) ) ? $post['mt_tickets'][ $model ] : array(); - $pricing_array = mt_setup_pricing( $labels, $prices, $availability, $close ); + $model_defaults = ( isset( $post['defaults'][ $model ] ) ) ? $post['defaults'][ $model ] : array(); + $labels = ( isset( $post['mt_label'][ $model ] ) ) ? $post['mt_label'][ $model ] : array(); + $prices = ( isset( $post['mt_price'][ $model ] ) ) ? $post['mt_price'][ $model ] : array(); + $close = ( isset( $post['mt_close'][ $model ] ) ) ? $post['mt_close'][ $model ] : array(); + $availability = ( isset( $post['mt_tickets'][ $model ] ) ) ? $post['mt_tickets'][ $model ] : array(); + $pricing_array = mt_setup_pricing( $labels, $prices, $availability, $close ); $defaults[ $model ] = $model_defaults; $defaults[ $model ]['pricing'] = $pricing_array; $defaults[ $model ]['tickets'] = ( is_array( $mt_total_tickets ) ) ? $mt_total_tickets[ $model ] : $mt_total_tickets; - $defaults[ $model ]['multiple'] = ( isset( $post['defaults']['multiple'] ) ) ? $post['defaults']['multiple'] : ''; + $defaults[ $model ]['multiple'] = ( isset( $post['defaults']['multiple'] ) ) ? $post['defaults']['multiple'] : ''; } /** @@ -72,6 +73,7 @@ function mt_update_ticketing_settings( $post ) { 'mt_settings', array( 'defaults' => $defaults, + 'default_model' => $default_model, 'mt_shipping' => $mt_shipping, 'mt_handling' => $mt_handling, 'mt_ticket_handling' => $mt_ticket_handling, @@ -91,7 +93,7 @@ function mt_update_ticketing_settings( $post ) { $_POST ); $settings = array_merge( get_option( 'mt_settings', array() ), $settings ); - // update_option( 'mt_settings', $settings ); + update_option( 'mt_settings', $settings ); /** * Filter updated settings messages appended to the 'My Tickets Ticketing Defaults saved' message. * @@ -240,6 +242,14 @@ function mt_ticketing_settings() {

+
+ + +
$discrete, 'event' => $showtime, ), + 'default_model' => 'continuous', 'messages' => $messages, 'mt_post_types' => array( 'mc-events', 'page' ), 'mt_license_key' => '',