You are here

function rooms_unit_get_unit_options in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Returns the available room options given a bookable unit.

Parameters

RoomsUnit $unit: The bookable unit to get options.

Return value

array The available options for the given bookable unit.

9 calls to rooms_unit_get_unit_options()
AvailabilityAgent::compareByOptionals in modules/rooms_booking/includes/rooms_booking.availability_agent.inc
Compares two bookable units based on the number of available options.
book_units_per_type_form in modules/rooms_booking_manager/rooms_booking_manager.module
Book units per type booking form callback.
book_units_per_type_form_submit in modules/rooms_booking_manager/rooms_booking_manager.module
Submit callback for book_units_per_type_form form.
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.
book_unit_form_submit in modules/rooms_booking_manager/rooms_booking_manager.module
Submit callback for book_unit_form form.

... See full list

File

modules/rooms_unit/rooms_unit.module, line 704
Manage units - Units are things that can be booked on a nightly basis (e.g. rooms - but also villas bungalows, etc).

Code

function rooms_unit_get_unit_options($unit) {
  $options =& drupal_static(__FUNCTION__);
  if (isset($options['units'][$unit->unit_id])) {
    return $options['units'][$unit->unit_id];
  }
  if (isset($options['unit_types'][$unit->type])) {
    $unit_type_options = $options['unit_types'][$unit->type];
  }
  else {
    $unit_type = rooms_unit_type_load($unit->type);
    $unit_type_options = is_array(field_get_items('rooms_unit_type', $unit_type, 'rooms_booking_unit_options')) ? field_get_items('rooms_unit_type', $unit_type, 'rooms_booking_unit_options') : array();
    $options['unit_types'][$unit->type] = $unit_type_options;
  }
  $unit_options = is_array(field_get_items('rooms_unit', $unit, 'rooms_booking_unit_options')) ? field_get_items('rooms_unit', $unit, 'rooms_booking_unit_options') : array();
  $options['units'][$unit->unit_id] = array_merge($unit_type_options, $unit_options);
  return $options['units'][$unit->unit_id];
}