Sanyy Posted December 18, 2017 Share Posted December 18, 2017 Hi, i have a issue with a booking plugin in Wordpress. If a room is booked, it is showing the room in search results just with a "NOT AVAILABLE" label. From a UX perspective it is a better option to not show it at all if the room is booked. I found the code controlling the issue: //available or not if ( nd_booking_is_qnt_available(nd_booking_is_available($nd_booking_id,$nd_booking_date_from,$nd_booking_date_to),$nd_booking_date_from,$nd_booking_date_to,$nd_booking_id) == 1 ) { $nd_booking_availability = ""; }else{ $nd_booking_availability = "<span class='nd_options_color_white nd_booking_font_size_10 nd_booking_line_height_10 nd_booking_letter_spacing_2 nd_booking_padding_3_5 nd_booking_top_10 nd_booking_position_absolute nd_booking_right_10 nd_booking_bg_yellow'>".__('NOT AVAILABLE','nd-booking')."</span>"; } I tried a few options but allways generate a blank page. Any idea what should be written after "else" so that the booked room won't show at all in search results. Cheers. Link to comment Share on other sites More sharing options...
requinix Posted December 19, 2017 Share Posted December 19, 2017 If you're having problems with your modified version of the code then you'll have to post your modified version of the code. Link to comment Share on other sites More sharing options...
BigB Posted December 19, 2017 Share Posted December 19, 2017 Hi. Just comment it out then? //available or not if ( nd_booking_is_qnt_available(nd_booking_is_available($nd_booking_id,$nd_booking_date_from,$nd_booking_date_to),$nd_booking_date_from,$nd_booking_date_to,$nd_booking_id) == 1 ) { $nd_booking_availability = ""; }else{ // DO NOTHING // --------- >> Commented out: $nd_booking_availability = "<span class='nd_options_color_white nd_booking_font_size_10 nd_booking_line_height_10 nd_booking_letter_spacing_2 nd_booking_padding_3_5 nd_booking_top_10 nd_booking_position_absolute nd_booking_right_10 nd_booking_bg_yellow'>".__('NOT AVAILABLE','nd-booking')."</span>"; } Link to comment Share on other sites More sharing options...
Sanyy Posted December 19, 2017 Author Share Posted December 19, 2017 Hi BigB, by commenting out, the room shows, just not available and no label. I enter "return:0;" then the room does not show, which is good, but a empty space shows instead, so when a pagination of 4 rooms is per page, it shows only 3 rooms, instead of 4. :/ Any idea? Link to comment Share on other sites More sharing options...
Barand Posted December 19, 2017 Share Posted December 19, 2017 Instead of of getting all rooms from your database then filtering out those that are unavailable, why don't you just pull the available rooms in the first place? Link to comment Share on other sites More sharing options...
Sanyy Posted December 19, 2017 Author Share Posted December 19, 2017 Hi Barand, yes that is the logical thing, but i am a PHP beginner, and trying to sort this out myself. The autor of the plugin did it like that, but for me it is not logical to display a booked room in a search result when looking for available rooms. Here is the full code: https://pastebin.com/sXmaUvap Do you have any idea what to edit and how? Cheers. Link to comment Share on other sites More sharing options...
Barand Posted December 19, 2017 Share Posted December 19, 2017 ... but for me it is not logical to display a booked room in a search result when looking for available rooms Exactly, so don't retrieve unavailable rooms from the database Link to comment Share on other sites More sharing options...
Sanyy Posted December 19, 2017 Author Share Posted December 19, 2017 Hi, ok, but what function or part is doing that in the code? Ty Link to comment Share on other sites More sharing options...
Barand Posted December 19, 2017 Share Posted December 19, 2017 Presumably you have a query that is retrieving the rooms from your database, When you display those results from the query you are testing if the room is available before displaying. That original query is the one to change. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.