You are here

public function AvailabilityAgent::checkAvailabilityForUnit in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Returns availability for a specific unit.

Parameters

int $unit_id: Bookable unit to check availability for.

array $price_modifiers: Price modifiers to apply.

Return value

array|int Bookable unit if available, error code otherwise.

File

modules/rooms_booking/includes/rooms_booking.availability_agent.inc, line 270
Contains the AvailabilityAgent.

Class

AvailabilityAgent
An AvailabilityAgent provides access to the availability functionality of Rooms and lets you query for availability, get pricing information and create products that can be bought.

Code

public function checkAvailabilityForUnit($unit_id, $price_modifiers = array()) {

  // Load the unit.
  $unit = rooms_unit_load($unit_id);
  $units = $this
    ->getUnitsByPriceType(array(
    $unit_id => $unit,
  ), $price_modifiers);
  $units = array_pop($units);
  $units = array_pop($units);
  if (count($units) == 0) {
    return ROOMS_NO_ROOMS;
  }
  else {
    return $units;
  }
}