Display Availability Calendar in case 0 accomodations found

Free and Premium WordPress Plugins & Themes Forums WordPress Themes Alpenhouse Display Availability Calendar in case 0 accomodations found

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #897003
    Van Hove
    Participant

    Hello

    Is this ‘easy’ to do with AlpenHouse Theme and Elementor:
    in case the Search Availability results in “0 accomodations …”, we want to display the Availability calendar unter that result, to encourage the customer/guest to look for other dates.
    Can I do this with the available elements in AlpenHouse theme and Elementor?
    Regards,
    Carine

    #899298
    Steve
    Keymaster

    Hello Van Hove,

    I don’t see any solution with Elementor but you can copy
    \plugins\motopress-hotel-booking\templates\shortcodes\search-results\results-info.php
    to your theme
    you_theme_name\hotel-booking\shortcodes\search-results\results-info.php
    and add [mphb_availability_search] shortcode to display a form or just a “Back to Search” button.

    Skills in php are required.

    #902004
    Van Hove
    Participant

    Hello Steve,
    I hope i understood correctly. I have a child theme alpenhouse-child under which i have now copied the parent’s results-info.php file.
    How can i now have the availability calendar shown under the default no-accommodations-found text? What should i add where in the else-clause of below code.
    I indeed have no PHP-knowledge indeed but i turst WP is also for non-PHP programmers, so i guess it must be possible to work safely in a child-theme file with your help i guess.
    Look forward to your reply.
    Carine

    
    <?php
    /**
     * Available variables
     * - int $roomTypesCount count of found rooms
     * - int $adults
     * - int $children
     * - string $checkInDate date in human readable format
     * - string $checkOutDate date in human readable format
     */
    if ( !defined( 'ABSPATH' ) ) {
    	exit;
    }
    ?>
    <p class="mphb_sc_search_results-info">
    	<?php
    	if ( $roomTypesCount > 0 ) {
    		printf( _n( '%s accommodation found', '%s accommodations found', $roomTypesCount, 'motopress-hotel-booking' ), $roomTypesCount );
    	} else {
    		_e( 'No accommodations found', 'motopress-hotel-booking' );
    	}
    	printf( __( ' from %s - till %s', 'motopress-hotel-booking' ), $checkInDate, $checkOutDate );
    //	printf( __( ' for adults: %d, children: %d', 'motopress-hotel-booking' ), $adults, $children );
    //	printf( __( ' from %s - till %s', 'motopress-hotel-booking' ), $checkInDate, $checkOutDate );
    	?>
    </p>
    #907388
    J. Davis
    Keymaster

    Hi Carine,

    Thank you for your question. Yes, you will need to add /hotel-booking/shortcodes/search-results/ folders inside of child theme folder so complete directory structure will look like this

    alpenhouse-child\hotel-booking\shortcodes\search-results\

    you should paste the copy of results-info.php file from this folder

    \plugins\motopress-hotel-booking\templates\shortcodes\search-results\

    Then edit results-info.php file at new destination adding
    echo do_shortcode('[mphb_availability_search]'); e.g.

    <?php
    /**
     * Available variables
     * - int $roomTypesCount count of found rooms
     * - int $adults
     * - int $children
     * - string $checkInDate date in human readable format
     * - string $checkOutDate date in human readable format
     */
    if ( !defined( 'ABSPATH' ) ) {
    	exit;
    }
    ?>
    <p class="mphb_sc_search_results-info">
    	<?php
    	if ( $roomTypesCount > 0 ) {
    		printf( _n( '%s accommodation found', '%s accommodations found', $roomTypesCount, 'motopress-hotel-booking' ), $roomTypesCount );
    	} else {
    		_e( 'No accommodations found', 'motopress-hotel-booking' );
    	}
    	printf( __( ' from %s - till %s', 'motopress-hotel-booking' ), $checkInDate, $checkOutDate );
    	echo do_shortcode('[mphb_availability_search]');
    //	printf( __( ' for adults: %d, children: %d', 'motopress-hotel-booking' ), $adults, $children );
    //	printf( __( ' from %s - till %s', 'motopress-hotel-booking' ), $checkInDate, $checkOutDate );
    	?>
    </p>

    Best regards,
    J. Davis

    #1050380
    Dan Sutherland
    Participant

    This does not appear correct, the class SearchResultsShortcode is manually setting the output string when a search error is thrown (no specific details on what an error is defined as!?)

    It is set via private function parseCheckOutDate so I cannot see any way to amend this without plugin updates wiping out changes.

    What may be happening is that errors are returning as a consequence of search parameters not meeting booking rules, whereas the above template triggers if no errors but where $roomTypesCount = 0 – if this is the case then we should have a template for both: no availability (when booking rules are met) and search errors (when booking rules are not met)

    #1050763
    Andre Flores
    Moderator

    Hello Dan,

    The idea is that you should override search results code in the child theme in order to prevent changes from being lost after the plugin update. So far the search results depend on selected dates only, so whether booking rules are met or not, the same error will be returned.

    Regards,
    Andre

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.