How can i input the opening hours manually ?

This topic contains 3 replies, has 3 voices, and was last updated by  Kiran 4 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #500865

    Kevin Lambert
    Full Member
    Post count: 11

    Dear GeoDirectory Team,

    My Customer wants to input the opening time himself without the Time picker, can you provide a code snippet to achieve that ?

    Thanks and best regards

    Kevin Lambert

    #500876

    Kor
    Moderator
    Post count: 16516

    Hi Kevin Lambert,

    Thanks for your post. Unfortunately, this isn’t possible without customization. Maybe you can just create a new custom field for this and allow text input as opening hours?

    #500878

    Kevin Lambert
    Full Member
    Post count: 11

    Ok, I see.

    But I want to keep the function on the front page (see screenshot)

    Can you provide the snippet for the customization or do i need to get in touch with a developer again?

    Thanks and best regards

    #500917

    Kiran
    Moderator
    Post count: 7069

    Hi Kevin,

    Business hours needs to stored in specific format in database, otherwise it will not work as expected.
    Ex: https://github.com/AyeCode/geodirectory/blob/master/includes/admin/dummy-data/standard_places.php#L188
    https://github.com/AyeCode/geodirectory/blob/master/includes/admin/dummy-data/standard_places.php#L842

    Try following PHP snippet to use normal text input for business hours.

    
    
    function gd_snippet_190802_cfi_business_hours( $html, $cf ) {
    	$label = __( $cf['frontend_title'], 'geodirectory' );
    	$description = __( $cf['desc'], 'geodirectory' );
    	$value = geodir_get_cf_value( $cf );
    	if(isset($cf['validation_pattern']) && $cf['validation_pattern']){
    		$validation = ' pattern="'.$cf['validation_pattern'].'" ';
    	}else{$validation='';}
    
    	// validation message
    	if(isset($cf['validation_msg']) && $cf['validation_msg']){
    		$validation_msg = 'title="'.$cf['validation_msg'].'"';
    	}else{$validation_msg='';}
    
    	if ( ! empty( $value ) ) {
    		$value = stripslashes_deep( $value );
    	}
    
    	ob_start();
    	?>
    	<div id="<?php echo $cf['name'];?>_row"
    		 class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details">
    		<label for="<?php echo esc_attr( $cf['name'] ); ?>"> <?php echo $label; ?> <?php if ($cf['is_required']) echo '<span>*</span>';?>
    		</label>
    		<input field_type="text" name="<?php echo $cf['name'];?>" id="<?php echo $cf['name'];?>" placeholder="<?php echo esc_attr( '["Mo 09:00-17:00","Tu 09:00-17:00","We 09:00-17:00"],["UTC":"+0"]' ); ?>" value="<?php echo esc_attr( $value ); ?>" type="text" class="geodir_textfield" <?php echo $validation;echo $validation_msg;?> />
    		<span class="geodir_message_note"><?php echo $description; ?></span>
    		<?php if ($cf['is_required']) { ?>
    			<span class="geodir_message_error"><?php _e($cf['required_msg'], 'geodirectory'); ?></span>
    		<?php } ?>
    	</div>
    	<?php
    	$html = ob_get_clean();
    	
    	return $html;
    }
    add_filter( 'geodir_custom_field_input_business_hours', 'gd_snippet_190802_cfi_business_hours', 20, 2 );

    Kiran

Viewing 4 posts - 1 through 4 (of 4 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket