Storing (autocomplete) client information

Hi there,

Most of my appointments are booked over the phone, so I have to enter the client information manually. I am wondering if there is a way to store a client's information or at least have it autocomplete so I don't need to look it up every time? Also, I am wondering if you have created the feature to have recurring appointments yet?

Thanks,
Toko-pa

  • Ash

    Hello @Toko-pa

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    Most of my appointments are booked over the phone, so I have to enter the client information manually. I am wondering if there is a way to store a client's information or at least have it autocomplete so I don't need to look it up every time?

    Are you booking from front end or admin end? By default if any user is logged in, the front end form is autocompleted with the logged in user's information. Please let me know.

    Also, I am wondering if you have created the feature to have recurring appointments yet?

    I am afraid, that feature is not available yet, neither we have any ETA.

    Cheers
    Ash

  • Ash

    Hi there

    Please try the following code:

    add_action( 'admin_head', 'app_auto_complete' );
    function app_auto_complete() {
    	?>
    	<script type="text/javascript">
    	jQuery(function($) {
    		$(document).on( 'change', 'select#user', function() {
    			var _this = $(this);
    			var id = $(this).val();
    			if( id != '' ){
    				var data = {
    					user_id: id,
    					action: 'get_app_user_select_details'
    					};
    				$.post( '<?php echo admin_url( 'admin-ajax.php' ) ?>', data, function( response ) {
    					var obj = $.parseJSON( response );
    					_this.closest('.inline-edit-col')
    							.find('input[name=cname]').val(obj.name)
    							.end()
    							.find('input[name=email]').val(obj.email)
    							.end()
    							.find('input[name=phone]').val(obj.phone)
    							.end()
    							.find('input[name=address]').val(obj.address)
    							.end()
    							.find('input[name=city]').val(obj.city);
    				});
    			}
    		});
    	});
    	</script>
    	<?php
    }
    
    add_action( 'wp_ajax_get_app_user_select_details', 'get_app_user_select_details' );
    function get_app_user_select_details() {
    	$user_id = $_POST['user_id'];
    	$user = new WP_User( $user_id );
    	$data = new stdClass();
    	$data->name =
    			get_user_meta( $user_id, 'app_name', true ) != '' ?
    				get_user_meta( $user_id, 'app_name', true ) :
    				$user->display_name;
    	$data->email =
    			get_user_meta( $user_id, 'app_email', true ) != '' ?
    				get_user_meta( $user_id, 'app_email', true ) :
    				$user->user_email;
    	$data->phone = get_user_meta( $user_id, 'app_phone', true );
    	$data->address = get_user_meta( $user_id, 'app_address', true );
    	$data->city = get_user_meta( $user_id, 'app_city', true );
    
    	echo json_encode( $data );
    
    	die();
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.