Snippet to change the price format only when the initial page is loaded

Hello,

  1. Code snippet:
add_filter(
	'hivepress/v1/models/listing/fields',
	function( $fields, $model ) {
		if ( isset( $fields['price'] ) ) {
			$fields['price']['display_template'] = 'from %value% /night*';
		}

		return $fields;
	},
	1000,
	2
);

work!
But to display the correct price after select the dates in the calendar doesn’t work…
Maybe you have a code snipped, that removes this “from” after selecting the dates - so only the calculated price at the end should be displayed?
So we need a snippet to change the price format only when the initial page is loaded.

  1. The price after selecting the days does not change… even after I emptied the cashe. The total price is only displayed when I go to Boock. Would it be possible to fix the inconsistent calculation bug as soon as possible?

https://south-crete.net/tourism/listing/villa-rodanthi/


Thank you for reporting this. We will check this issue detailed and fix it as soon as possible

Hello Yevhen,
can we have (until the problem is solved) a Snippet to change the price format ONLY WHEN the initial page is loaded ?
The problem is that Supplement Price “from” is displayed even after selecting days. “From” must be gone at price Total.
That would be very helpful for us.

Please try this PHP snippet

add_filter(
	'hivepress/v1/models/listing/fields',
	function( $fields ) {
		if(hivepress()->helper->is_rest()){
			return $fields;
		}
		
		$fields['price']['display_template'] = 'custom text/%value%';

		return $fields;
	},
	1000
);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.