fix logic for discounted booking rate
This commit is contained in:
@@ -20,6 +20,7 @@ function booking_register_page()
|
|||||||
|
|
||||||
$allowed_time_check = ($booking_times->booking_register_open < time()) && ($booking_times->booking_register_close > time());
|
$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);
|
$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) {
|
if ($allowed_time_check || $earlyaccess_time_check) {
|
||||||
//we are within the allowed timeframe for registrations
|
//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
|
//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(
|
$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()) {
|
} elseif ($booking_times->booking_register_close < time()) {
|
||||||
//too late to register
|
//too late to register
|
||||||
@@ -86,20 +87,26 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all
|
|||||||
$data = $form_state['input'];
|
$data = $form_state['input'];
|
||||||
//watchdog('booking', 'Booking registration form loading data from form submission: @info', array('@info' => var_export($form_state, TRUE)));
|
//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');
|
$price_query = db_select('booking_price', 'p');
|
||||||
$db_and = db_and()->condition('p.booking_eventid', $event->eid, '=')
|
$db_and = db_and()->condition('p.booking_eventid', $event->eid, '=')
|
||||||
->condition('p.booking_price_active', 1, '=')
|
->condition('p.booking_price_active', 1, '=')
|
||||||
->condition('p.booking_depositonly', 0, '=');
|
->condition('p.booking_depositonly', 0, '=');
|
||||||
$price_query->condition($db_and);
|
$price_query->condition($db_and);
|
||||||
$price_query->fields('p');
|
$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
|
// Registrations are open and before early bird closes
|
||||||
$early_payment_flag = $select_early || $early_access_allowed;
|
$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) {
|
foreach ($result as $row) {
|
||||||
$price = $early_payment_flag == TRUE ? $row->booking_price : $row->booking_late_price;
|
$price = $early_payment_flag == TRUE ? $row->booking_price : $row->booking_late_price;
|
||||||
|
Reference in New Issue
Block a user