You are here

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

Allows to modify the price modifiers array for a booking.

Parameters

array $price_modifiers: Array containing the booking price modifiers.

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 function implements hook_rooms_price_modifier_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

rooms_periodic_pricing_rooms_price_modifier_alter in modules/rooms_pricing/modules/rooms_periodic_pricing/rooms_periodic_pricing.module
Implements hook_rooms_price_modifier_alter().
5 invocations of hook_rooms_price_modifier_alter()
AvailabilityAgent::getUnitsByPriceType in modules/rooms_booking/includes/rooms_booking.availability_agent.inc
Returns the units array in a specific format based on price.
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.
rooms_booking_edit_form in modules/rooms_booking/rooms_booking.admin.inc
Form callback: create or edit a booking.
rooms_booking_manager_price_apply in modules/rooms_booking_manager/rooms_booking_manager.module
Calculates the price for rooms_booking line item types.

File

modules/rooms_booking/rooms_booking.api.php, line 28
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_price_modifier_alter(&$price_modifiers, $booking_info) {

  // This adds programmatically a 10$ discount.
  $price_modifiers['my_module'] = array(
    '#type' => ROOMS_DYNAMIC_MODIFIER,
    '#quantity' => 1,
    '#op_type' => ROOMS_SUB,
    '#amount' => 10,
  );
}