You are here

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

Update line item "Booking Dates" value to include time.

File

modules/rooms_booking_manager/rooms_booking_manager.install, line 394
Install for Rooms Booking Manager module

Code

function rooms_booking_manager_update_7007() {
  foreach (commerce_line_item_load_multiple(FALSE, array(
    'type' => 'rooms_booking',
  )) as $line_item) {
    if (isset($line_item->rooms_booking_dates[LANGUAGE_NONE][0]['value'])) {
      $value = new DateTime($line_item->rooms_booking_dates[LANGUAGE_NONE][0]['value']);
      $value2 = new DateTime($line_item->rooms_booking_dates[LANGUAGE_NONE][0]['value2']);
      $line_item->rooms_booking_dates[LANGUAGE_NONE][0]['value'] = $value
        ->format('Y-m-d') . 'T00:00:00';
      $line_item->rooms_booking_dates[LANGUAGE_NONE][0]['value2'] = $value2
        ->format('Y-m-d') . 'T00:00:00';
      field_attach_update('commerce_line_item', $line_item);
    }
  }
}