Changed Price per Day to Price per Hour but it's not working

I’ve changed the text on the Display section in Listings>Attributes from “Day” to “Hour” but on the Listing page it still displays “Day” - please see screenshots below for further detail.


Please try this PHP snippet Change the price display format for marketplace listings #hivepress #marketplace · GitHub

That code doesn’t work - I’ve entered into the Attributes>Price section, doesn’t do anything

I’ve tried changing the format several times, even reverting it back to the original text and updating the settings but it doesn’t seem to be changing at all - is the broken/corrupted or am I missing something here? (please see screenshots attached)


Please try this PHP snippet

add_filter(
	'hivepress/v1/models/listing/fields',
	function( $fields, $model ) {
		if ( isset( $fields['price'] ) ) {
			$fields['price']['display_template'] = '%value% / per Hour';
		}

		return $fields;
	},
	1000,
	2
);

Hello,
And, if we want to show both, day and hour?

Please try to enable time slots setting and set time slots categories in HivePress/Settings/Bookings. Then please try to use this PHP snippet. It will change the display format for the price attribute only for categories where time slots are enabled. Other listings will have a display format for the price attribute with / day if the HivePress Marketplace extension is active

add_filter(
	'hivepress/v1/models/listing/fields',
	function( $fields, $listing ) {
		if (hivepress()->get_version( 'bookings' ) && hivepress()->booking->is_time_enabled( $listing->get_id()) && isset( $fields['price'] ) ) {
			$fields['price']['display_template'] = '%value% / per Hour';
		}

		return $fields;
	},
	1000,
	2
);
1 Like

Hi yevhen I’ve entered the code into the Price Attributes section but still isn’t displaying properly on the website - are there any other solutions?

This format worked initially but I can’t remember what the original looked like in the text box - it was somthing like £%value% per Hour

Screenshot 2022-07-13 at 22.27.14

If you use the Marketplace & Bookings extensions, this custom format of the Price attribute will not work because the Price field is added by the extensions, attributes in Listings/Attributes don’t affect its display. Please try using the code snippet above, it should override the Price display format if it’s added via the Code Snippets plugin.

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