function rooms_booking_manager_check_for_deposit in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Checks if deposit is active and returns deposit amount.
Parameters
$price:
$start_date:
Return value
bool|float|null
2 calls to rooms_booking_manager_check_for_deposit()
- book_units_per_type_form in modules/
rooms_booking_manager/ rooms_booking_manager.module - Book units per type booking form callback.
- book_unit_form_builder in modules/
rooms_booking_manager/ rooms_booking_manager.module - The form builder builds the form (where visible is simply the purchase button) for individual bookable units.
File
- modules/
rooms_booking_manager/ rooms_booking_manager.module, line 3312 - Rooms Booking Manager brings together all the pieces required to find a room and book it - including the DrupalCommerce integration
Code
function rooms_booking_manager_check_for_deposit($price, $start_date) {
$deposit_amount = FALSE;
if (variable_get('rooms_booking_manager_full_payment', 0)) {
$now = new DateTime();
$interval = '+ ' . format_interval(variable_get('rooms_booking_manager_full_payment_duration', 86400));
$now
->modify($interval);
if ($start_date <= $now) {
return $deposit_amount;
}
}
$rule = rules_config_load('rooms_booking_manager_deposit');
if (!empty($rule) && $rule->active) {
$deposit_type = variable_get('rooms_booking_manager_deposit_type');
$deposit_amount = $deposit_type == 'commerce_line_item_unit_price_amount' ? variable_get('rooms_booking_manager_deposit_fixed') : variable_get('rooms_booking_manager_deposit_multiply') * $price / 100;
}
return $deposit_amount;
}