From c0f076b889677774ba8133f56b54938ec8980838 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sat, 13 Jan 2018 13:13:30 +1100 Subject: [PATCH] fix logic for discounted booking rate --- booking.regn_form.inc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/booking.regn_form.inc b/booking.regn_form.inc index 9f8a06a..b2ec356 100644 --- a/booking.regn_form.inc +++ b/booking.regn_form.inc @@ -20,6 +20,7 @@ function booking_register_page() $allowed_time_check = ($booking_times->booking_register_open < time()) && ($booking_times->booking_register_close > time()); $earlyaccess_time_check = ($booking_times->booking_register_close > time()) && (variable_get('booking_enable_earlyaccess_codes', 0) == 1); + $before_regn_open_check = ($booking_times->booking_register_open > time()); if ($allowed_time_check || $earlyaccess_time_check) { //we are within the allowed timeframe for registrations @@ -38,7 +39,7 @@ function booking_register_page() ); //even if we are allowed to show the early access code, only show it if it is prior to the normal registration opening time $return_array[] = array( - 'form' => drupal_get_form('booking_form', true, ($booking_times->booking_register_open > time())) + 'form' => drupal_get_form('booking_form', true, $before_regn_open_check) ); } elseif ($booking_times->booking_register_close < time()) { //too late to register @@ -86,20 +87,26 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all $data = $form_state['input']; //watchdog('booking', 'Booking registration form loading data from form submission: @info', array('@info' => var_export($form_state, TRUE))); } - - //figure out if we're in the earlybird rate section and use that for determining pricing - $select_early = _booking_is_earlybird(); - + $price_query = db_select('booking_price', 'p'); $db_and = db_and()->condition('p.booking_eventid', $event->eid, '=') ->condition('p.booking_price_active', 1, '=') ->condition('p.booking_depositonly', 0, '='); $price_query->condition($db_and); $price_query->fields('p'); - $result = $price_query->execute(); + $result = $price_query->execute(); + + //figure out if we're in the earlybird rate section and use that for determining pricing - // allow discounted payments if we're in early rates or early access is allowed - $early_payment_flag = $select_early || $early_access_allowed; + // Registrations are open and before early bird closes + $earlybird_check = (($event->booking_register_open <= time()) && ($event->booking_earlybird_close > time())); + // Early access is allowed and the time now is before registrations would normally open + $earlyaccess_check = ((variable_get('booking_enable_earlyaccess_codes', 0) == 1) && ($event->booking_register_open > time())); + + // discounted payments is allowed if: + // - early access allowed and before registrations start + // - early access not allowed and after earlybird start but before earlybird finish + $early_payment_flag = $earlybird_check || $earlyaccess_check; foreach ($result as $row) { $price = $early_payment_flag == TRUE ? $row->booking_price : $row->booking_late_price;