From d568cf2043998c01987b58b9d371f14457295503 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 29 Aug 2017 22:36:08 +1000 Subject: [PATCH] allow discounted rate for early access registrations --- booking.helper.inc | 18 +++++++++++++++++- booking.regn_form.inc | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/booking.helper.inc b/booking.helper.inc index 94814e1..70246d0 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -801,6 +801,22 @@ function _booking_is_earlybird() { } } +//figure out if we're in the right time period for discounted registration rates +function _booking_is_earlyaccess() { + global $event; + + if (variable_get('booking_enable_earlyaccess_codes', 0) == 1) { + $booking_times = db_query("SELECT booking_register_open, booking_register_close FROM {booking_event} where eid = :eid", + array(':eid' => $event->eid))->fetchObject(); + + //if we're now before the time that registrations open, then this registration must be from the early access time period + return ($booking_times->booking_register_open > time()); + } + + //if the feature isn't enabled then just return false + return FALSE; +} + function _booking_datepaid_ts($nid) { $query = db_query("SELECT * FROM {booking_payment} where booking_person_nid = :nid", array(':nid' => $nid)) ->fetchObject(); @@ -966,7 +982,7 @@ function _booking_total_due($person) $total_due = $person->booking_total_pay_reqd; } //the early bird rate will be defined by default for the registration - elseif (_booking_is_earlybird() == TRUE) + elseif (_booking_is_earlybird() == TRUE || _booking_is_earlyaccess() == TRUE) { $total_due = $person->booking_total_pay_reqd; } diff --git a/booking.regn_form.inc b/booking.regn_form.inc index 4144feb..da1a6d6 100644 --- a/booking.regn_form.inc +++ b/booking.regn_form.inc @@ -199,8 +199,8 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all $form['your-details']['booking_dob']['#date_year_range'] = $date_year_range; } - $early_description_text = t("Please note that this is the discounted payment rate. Fore more information about payment rates, please see !theweek", - array('!theweek' => l('The Week page', 'the-week/whats-happening'))); + $early_description_text = t("Please note that this is the discounted payment rate. For more information about payment rates, please see !theweek page.", + array('!theweek' => l('The Week', 'the-week/whats-happening'))); $form['your-details']['booking_payment_id'] = array( '#type' => 'select', '#title' => t('Choose your payment type'),