Okay
  Public Ticket #1371331
Room type order
Closed

Comments

  • Adrian9Delg started the conversation

    Hi

    How can I order the room types by price (lowest to highest) under the Availability tab in every hotel page?

  •  2,057
    Theme replied

    Hi,

    At the moment that is not possible. We hope to implement this feature in the near future.

    Thanks,

    Best regards,

    themeenergy support

  • Adrian9Delg replied

    Can you tell me what's the logical order the theme is using now to display the room types? I tried changing prices, post published date and vacancies, I'm thinking it could be sorted by post id, I just need a clue to let my partners know in what order they should submit the room types.

  •  2,057
    Theme replied

    Hi,

    Yes, the room types are ordered by ID.

    If you go to single-accommodation.php you will find that the room types are obtained as follows:

    $room_type_ids = $accommodation_obj->get_room_types();

    If you wanted to sort them by price, you could edit the file, and look at these lines:

    for ( $z = 0; $z < count($room_type_ids); $z++ ) {
        $room_type_id = $room_type_ids[$z];
        $room_type_obj = new BookYourTravel_Room_Type(intval($room_type_id));
        $room_type_price = $bookyourtravel_accommodation_helper->get_accommodation_price($accommodation_id, $room_type_id);
    

    You could change them to:

    $room_type_prices = array();
    for ( $z = 0; $z < count($room_type_ids); $z++ ) {
        $room_type_id = $room_type_ids[$z];
        $room_type_price = $bookyourtravel_accommodation_helper->get_accommodation_price($accommodation_id, $room_type_id);
        $room_type_prices[$room_type_id] = $room_type_price;
    }
    foreach ($room_type_prices as $room_type_id => $room_type_price) {
        $room_type_obj = new BookYourTravel_Room_Type(intval($room_type_id));

    By doing the above, you would have the room types listed in order by price.

    Best regards,

    themeenergy support

  • Adrian9Delg replied

    It's not working, I changed the code as directed and nothing happened, see the picts one is the live results and the other is the code inserted in the php directly in my hosting.

    The idea is to have the rooms sorted by price (lowest to highest) the way booking, expedia and most travel website uses.

  •  2,057
    Theme replied

    My bad,

    Please change this:

    foreach ($room_type_prices as $room_type_id => $room_type_price) {

    to

    asort($room_type_prices);
    foreach ($room_type_prices as $room_type_id => $room_type_price) {

    Best regards,

    themeenergy support

  • Adrian9Delg replied

    Working perfectly now thanks.