You are here

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

Ensures the booking line item type contains a product reference field and all other rooms fields required for a booking.

Parameters

array $line_item_type: The line item type object.

File

modules/rooms_booking_manager/rooms_booking_manager.module, line 3227
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_line_item_configuration($line_item_type) {
  $type = $line_item_type['type'];

  // Get the info about the fields and instances we need to create.
  module_load_include('inc', 'rooms_booking_manager', 'includes/rooms_booking_manager.fields');
  $field_data = _rooms_booking_manager_line_item_type_fields();

  // Create the product reference field for the line item type.
  commerce_product_line_item_configuration($line_item_type);

  // For each field, check whether it already exists create it if it doesn't
  foreach ($field_data['fields'] as $field_name => $field_info) {
    $field = field_info_field($field_name);
    $instance = field_info_instance('commerce_line_item', $field_name, $type);
    if (empty($field)) {
      field_create_field($field_data['fields'][$field_name]);
    }
    if (empty($instance)) {
      field_create_instance($field_data['instances'][$field_name]);
    }
  }
}