I would like to show ‘booking slot duration’ on the cover (in small format) of each ad before opening it to read it.
Hi,
Please try this PHP snippet:
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
if ( isset( $attributes['booking_slot_duration'] ) ) {
$attributes['booking_slot_duration']['display_areas'] = [ 'view_page_primary', 'view_block_secondary' ];
}
return $attributes;
},
1000
);
add_filter(
'hivepress/v1/fields/number/display_value',
function( $value, $field ) {
if ( $field->get_name() === 'booking_slot_duration' ) {
$hour = intdiv( $value, 60 );
if($hour < 10){
$hour = '0'.$hour;
}
$minute = $value % 60;
if(intval($minute) < 10){
$minute = '0'.$minute;
}
$value = '<i class="hp-icon fas fa-fw fa-clock"></i> Duration: ' . $hour . ':' . $minute;
}
return $value;
},
1000,
2
);
Also, please check this topic, if you need more information - Listing duration / Time Availability not working correctly - #21 by aqmiami7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.