Change order of fields in the search form

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1158392
    Michael Carrier
    Participant

    I wanted to see if I could put an attribute before the check-in field on the search form.

    #1158535
    Andre Flores
    Moderator

    Hello Mochael,

    Yes, it is possible by overriding default [mphb_availability_search] shortcode function. In order to do that copy the search-form.php file from /wp-content/plugins/motopress-hotel-booking/templates/shortcodes/search/ directory to /wp-content/themes/your-child-theme/hotel-booking/shortcodes/search/ directory and place the below code:

    <?php do_action( 'mphb_sc_search_form_before_attributes' ); ?>
    
    	<?php foreach ( $attributes as $attributeName => $terms ) { ?>
    		<p class="<?php echo esc_attr( 'mphb_sc_search-' . $attributeName ); ?>">
    			<label for="<?php echo esc_attr( 'mphb_' . $attributeName . '-' . $uniqid ); ?>">
    				<?php echo esc_html( mphb_attribute_title( $attributeName ) ); ?>
    			</label>
    			<br />
    			<select id="<?php echo esc_attr( 'mphb_' . $attributeName . '-' . $uniqid ); ?>" name="<?php echo esc_attr( 'mphb_attributes[' . $attributeName . ']' ); ?>">
    				
    				<?php foreach ( $terms as $termId => $termLabel ) { ?>
    					<option value="<?php echo esc_attr( $termId ); ?>"><?php echo esc_html( $termLabel ); ?></option>
    				<?php } ?>
    			</select>
    		</p>
    	<?php } ?>

    Above the following code:

    <p class="mphb_sc_search-check-in-date">
    		<label for="<?php echo esc_attr( 'mphb_check_in_date-' . $uniqid ); ?>">
    			<?php _e( 'Check-in', 'motopress-hotel-booking' ); ?>
    			<abbr title="<?php printf( _x( 'Formatted as %s', 'Date format tip', 'motopress-hotel-booking' ), MPHB()->settings()->dateTime()->getDateFormatJS() ); ?>">*</abbr>
    		</label>
    		<br />
    		<input
    			id="<?php echo esc_attr( 'mphb_check_in_date-' . $uniqid ); ?>"
    			data-datepick-group="<?php echo esc_attr( $uniqid ); ?>"
    			value="<?php echo esc_attr( $checkInDate ); ?>"
    			placeholder="<?php _e( 'Check-in Date', 'motopress-hotel-booking' ); ?>"
    			required="required"
    			type="text"
    			name="mphb_check_in_date"
    			class="mphb-datepick"
    			autocomplete="off"
    			/>
    	</p>

    Make sure to perform changes in file copied to your child theme directory in order to prevent changes from being lost after future theme updates.

    Regards,
    Andre

    #1158906
    Michael Carrier
    Participant

    Ok, thanks for the solution.

    #1159219
    Andre Flores
    Moderator

    You are most welcome. It would be very much appreciated if you share your positive feedback about the Hotel Booking plugin at: https://www.trustpilot.com/evaluate/www.getmotopress.com.

    Thank you in advance!

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