add checks for earlyaccess

This commit is contained in:
2017-08-29 22:27:43 +10:00
parent a707ab2fd0
commit 57bf81dfa4

View File

@@ -97,10 +97,13 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all
$price_query->condition($db_and);
$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;
foreach ($result as $row) {
$price = $select_early == TRUE ? $row->booking_price : $row->booking_late_price;
$discount_suffix = $select_early == TRUE ? " - discounted rate" : "";
$price = $early_payment_flag == TRUE ? $row->booking_price : $row->booking_late_price;
$discount_suffix = $early_payment_flag == TRUE ? " - discounted rate" : "";
$payment_type_options[$row->pid] = $row->booking_price_descrip . ' ($' . $price . ')' . $discount_suffix;
}
@@ -201,7 +204,7 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all
$form['your-details']['booking_payment_id'] = array(
'#type' => 'select',
'#title' => t('Choose your payment type'),
'#description' => $select_early == TRUE ? $early_description_text : "",
'#description' => $early_payment_flag == TRUE ? $early_description_text : "",
'#default_value' => $inserting != TRUE ? $data->booking_payment_id : variable_get('booking_payment_id', 'worker'),
'#options' => $payment_type_options,
);