Price attribute change based on category

Hello HivePress team,

I am currently trying to change the price attribute based on the category.
For example let’s say you have a category short-stay when you want on the price to say “per hour” instead of “per night”.

I am using the below code to change how the price shows up, but I have no idea how to have a different one depending on the category.
Can you help me on that?

function( $fields, $model ) {
 if ( isset( $fields['price'] ) ) {
 $fields['price']['display_template'] = '%value% / day';

 return $fields;


Please try to restrict time slots by category in HivePress > Settings > Bookings > Time Slots > Time Categories because if you change the price display format, the payment logic will not change if you have the Marketplace extension installed.

Hi Andrii,

I understand what you are saying but this still doesn’t solve my problem. I still have no control over what is shown as price. I would like to be able to change what it says with specific words of my choice. Your suggestion does separate them and shows them differently but I cannot change each one.

Please try using the suggested solution, this is the correct way to do this. In your example, you can restrict time slots to “short stays” category (this will enable hourly bookings for listings within this category), and other listings will have nightly bookings. This way time slot categories will display the slot price, and other listings will display the “$123 / night” format. You can change these words via Loco Translate if required.

understood, thank you Ihor and Andrii

1 Like

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