Prices start at:

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #786537
    Nick Shemenski
    Participant

    Currently on the availability page it shows:

    Prices start at: $447 for 3 nights

    I would like it to show the rate for one night, not 3 nights.
    In the settings I have a minimum stay set to 3 nights.
    How can I have it show a single night rate?

    Thank you

    #787079
    Stacy Lind
    Keymaster

    Our plugin cannot display prices per one night if you have minimum stay rules. This would require a custom solution. Here is how you can customize it:
    1. Add the following to wp-content\themes\your-child-theme\functions.php:

    function custom_mphb_tmpl_the_room_type_default_price( $id = null ){
    	$roomType = $id ? MPHB()->getRoomTypeRepository()->findById( $id ) : MPHB()->getCurrentRoomType();
    	$nights = 1;
    	$price  = mphb_get_room_type_base_price( $roomType );
    
    	$defaultPriceForNights = $price * $nights;
    
    	$taxesAndFees = $roomType->getTaxesAndFees();
    	$taxesAndFees->setRoomPrice( $defaultPriceForNights );
    	$taxesAndFees->setupParams( array(
    		'period_nights' => $nights,
    		'defined' => false
    	) );
    
    	$title = __( 'Choose dates to see relevant prices', 'motopress-hotel-booking' );
    
    	$priceFortmatAtts = array(
    		'period'		 => true,
    		'period_nights'	 => $nights,
    		'period_title'	 => $title
    	);
    
    	/**
    	 * @since 3.9.8
    	 *
    	 * @param float $defaultPriceForNights
    	 * @param \MPHB\TaxesAndFees\TaxesAndFees
    	 * @param array $priceFortmatAtts
    	 * @param float $defaultPriceForNights
    	 */
    	$formattedPrice = apply_filters( 'mphb_tmpl_the_room_type_price_for_dates',
    		mphb_format_price( $defaultPriceForNights, $priceFortmatAtts ),
    		$taxesAndFees,
    		$priceFortmatAtts,
    		$defaultPriceForNights
    	);
    	// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    	echo $formattedPrice;
    }

    2. Copy wp-content\plugins\motopress-hotel-booking\templates\loop-room-type\price.php into wp-content\themes\your-child-theme\hotel-booking\loop-room-type\price.php.
    3. In wp-content\themes\your-child-theme\hotel-booking\loop-room-type\price.php change the line 19 to the following:
    <?php custom_mphb_tmpl_the_room_type_default_price(); ?>
    It will always display prices per night unless your customer searchers for specific dates. We could also customize the code for you with the extended support offer.

    #787250
    Nick Shemenski
    Participant

    Thank you. That worked great.

    Can I also change it on the accommodation/beach-cottage/ page?
    Beach Cottage is the name of my accommodation.

    It still shows the 3 nights price there.

    Thank you

    #787932
    Stacy Lind
    Keymaster

    Hi Nick,

    1. Copy \wp-content\plugins\motopress-hotel-booking\templates\single-room-type\price.php into wp-content\themes\your-child-theme\hotel-booking\single-room-type\price.php.
    2. In wp-content\themes\your-child-theme\hotel-booking\single-room-type\price.php change the line 19 to the following:
    <?php custom_mphb_tmpl_the_room_type_default_price(); ?>

    #788119
    Nick Shemenski
    Participant

    Stacy,

    Thank you.

    #943682
    Edner Zephir
    Participant

    Hello,
    I enjoyed this post. Thanks to Stacy and Nick

    So, with this trick how can Stacy help me achieve the following:

    Minimum stay works in calendar only when I select all accommodation?
    Example: https://viprealtymanagers.com/alquiler/accommodation/villa-vanilla/

    Scenario

    1) Rule set only for this villa: https://prnt.sc/rynko6 > guest can select 1 day: https://prnt.sc/ryniyd. After checking for availability this villa not shown but it not make sense.
    2) Rule set for all accommodation: https://prnt.sc/rynlbk > in this case, yes it works > https://prnt.sc/rynly5 | https://prnt.sc/rynmi0

    #945559
    J. Davis
    Keymaster

    Hi Edner,

    In order to display and reflect the booking rules of certain accommodation type you should enable Skip Search results option at Accommodation > Settings. Then the date pick calendar will display available and not available dates of each accommodation type.

    best regards,
    J. Davis

    #1246972
    William Jepson
    Participant

    How can I also show the 1 night price on the homepage slider widget? Above code worked on 3 column accomodation but still shows 3 night price on slider widget.

    #1249341
    J. Davis
    Keymaster

    Hi William,

    You may try to add a custom function name custom_mphb_tmpl_the_room_type_default_price in the following file \wp-content\plugins\motopress-hotel-booking\templates\widgets\rooms\room-content.php

    instead of

    mphb_tmpl_the_room_type_default_price

    best regards,
    J. Davis

    #1316536
    Gundula Uray
    Participant

    Could this please be put behind a setting or even made the default. Otherwise it is really marketing gone wrong.

    #1318283
    Andre Flores
    Moderator

    Hello Gundula,

    Currently this is how the pricing functions by default in case you have a minimum stay rule set up.
    We might consider implementing this option in one of the plugin future updates.

    Best regards,
    Andre

    #1322324
    Gundula Uray
    Participant

    I have added the PHP hacks you suggested and it works in soe places. The motopress theme allows to filter by LOCATION as well and this is where it breaks and it still shows the price for 3 nights instead of showing the price for 1 night. See https://holapp.at/locations/rohrmoos-schladming/

    While the same appartement on this page is already showing the PER NIGHT PRICE.

    Pretty sure this needs another PHP hack in another place. This is pretty tedious and does not work in all places.

    What is worse is that the current implementation breaks with WPML multi lingual sites:
    a) the english site works fine and shows a price of 900 for 3 nights for the first appartement (appartement home TRINKER): https://holapp.at/locations/rohrmoos-schladming/
    b) the german translation using wpml breaks and shows 900 for 1 night!! which is clearly wrong:
    https://holapp.at/de/ort/rohrmoos/

    This is not a user friendly implementation. Fiddling with php is not something one of your clients should be doing pls even the current hacks do not cater for all instances and need further fiddling with php.

    Please please please put this under a setting that is clearly implemented, documented and tested by QA.

    #1325045
    J. Davis
    Keymaster

    Hi Gundula,

    Thanks for your feedback. I’ve added your request to our list of features. We will notify you if we have any news about it.

    best regards,
    J. Davis

    #1326618
    Gundula Uray
    Participant

    Thanks J.Davis. Could you please suggest a php hack for this:

    https://holapp.at/locations/rohrmoos-schladming/

    this is currently not covered by the two php hacks/modifications you guys noted above. it is still showing 3 nights in that section.
    regards!

    #1326880
    J. Davis
    Keymaster

    Hi Gundula,

    Since there was added custom archive page in the Booklium theme you will need to update the name of the function following the steps below:

    – go to the booklium-child theme folder on your server and open it
    – create template-parts folder
    – copy the following file from the parent theme folder
    /wp-content/themes/booklium/template-parts/content-taxonomy-mphb_room_type.php
    – paste the file to the child theme
    /wp-content/themes/booklium-child/template-parts/content-taxonomy-mphb_room_type.php
    – open the file you have pasted with any text editor and place custom_mphb_tmpl_the_room_type_default_price(); instead of mphb_tmpl_the_room_type_default_price();

    best regards,
    J. Davis

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