fix logic for discounted booking rate

This commit is contained in:
Nathan Coad
2018-01-13 13:13:30 +11:00
parent 0395b406a5
commit c0f076b889

View File

@@ -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
@@ -87,9 +88,6 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all
//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, '=')
@@ -98,8 +96,17 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all
$price_query->fields('p');
$result = $price_query->execute();
// allow discounted payments if we're in early rates or early access is allowed
$early_payment_flag = $select_early || $early_access_allowed;
//figure out if we're in the earlybird rate section and use that for determining pricing
// 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;