You are here

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

Allows modification of the booking price prior to the application of price modifiers.

Parameters

$price: The calculated booking amount.

array $booking_info: Array containing the booking information. Contains the following key/value pairs:

  • start_date: DateTime object containing the booking start date.
  • end_date: DateTime object containing the booking end date. In this case,

the end date represents the last night the unit is blocked, so it is one day before the checkout date entered in the booking form.

  • unit: The RoomsUnit entity the booking is related to.
  • booking_parameters: Array containing some other booking parameters:
    • group_size: The total number of persons included in the booking.
    • group_size_children: The number of children.
    • childrens_age: Array containing children's age.
1 invocation of hook_rooms_booking_amount_before_modifiers_alter()
UnitPricingCalendar::calculatePrice in modules/rooms_pricing/includes/rooms_pricing.unit_pricing_calendar.inc
Given a date range determine the cost of the room over that period.

File

modules/rooms_pricing/rooms_pricing.api.php, line 29
This file contains no working PHP code; it exists to provide additional documentation for doxygen as well as to document hooks in the standard Drupal manner.

Code

function hook_rooms_booking_amount_before_modifiers_alter(&$price, $booking_info) {

  // Hardcode a 100$ price whe booking longer than 5 days.
  $period = $booking_info['start_date']
    ->diff($booking_data['end_date'])->days + 1;
  if ($period > 5) {
    $price = 100;
  }
}