Would it be possible to filter the appointments by client?

I would like to filter the appointments by the client. I see that currently there is only the option to filter by "Service" or "Service Provider", would it be possible to add a filter for clients? Thanks.

  • Nithin
    • Support Wizard

    Hi Manjeet Singh,

    I'm pinging our SLS team regarding this and will get back to you once I get further feedback regarding whether there is any quick workaround.

    Please do note that this would require custom workaround, and if it's going to take a lot of custom changes, we might direct you to custom development.

    Will keep you posted once we get further update regarding the status of this query asap. Have a nice day ahead.

    Kind Regards,
    Nithin

  • Panos
    • SLS

    Hey there Manjeet Singh !

    So sorry for delay! You could try the following snippet which wraps the Client header with a new link that should filter the results by client's name with javascipt :

    add_action( 'admin_footer', function(){
    
    	if ( ! function_exists( 'get_current_screen' ) || 'toplevel_page_appointments' != get_current_screen()->id  ) {
    		return;
    	}
    
    	?>
    
     	<script type="text/javascript">
     		($=>{
    
     			var WPMUDEV_App_Admin_Orderby_client = {
    				load: function() {
    
    					// Wrap the Client spant with the sorting link
    	 				const
    	 					url = this.set_query_vars(),
    		 				link = $( '<a/>', {
    		 					'href' : url
    		 				}),
    		 				target = $( 'table.appointments #user' );
    		 				target.wrapInner( link );	
    
    				},
    
    				set_query_vars : function() {
    					let url = window.location.href,
    						order = this.get_query_var( 'order', url, 'desc' );
    
    						if ( 'asc' == order ) {
    							order = 'desc';
    						} else {
    							order = 'asc';
    						}
    
    						url = this.update_query_var( 'order', order, url );
    						url = this.update_query_var( 'orderby', 'name', url );
    
    					return url;
    				},
    
    				update_query_var : function( key, value, url ) {
    
    					if ( ! url ) url = window.location.href;
    				    var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi"),
    				        hash;
    
    				    if ( re.test( url ) ) {
    				        if ( typeof value !== 'undefined' && value !== null )
    				            return url.replace( re, '$1' + key + "=" + value + '$2$3' );
    				        else {
    				            hash = url.split( '#' );
    				            url = hash[0].replace( re, '$1$3' ).replace( /(&|\?)$/, '' );
    				            if ( typeof hash[1] !== 'undefined' && hash[1] !== null )
    				                url += '#' + hash[1];
    				            return url;
    				        }
    				    }
    				    else {
    				        if ( typeof value !== 'undefined' && value !== null ) {
    				            var separator = url.indexOf('?') !== -1 ? '&' : '?';
    				            hash = url.split( '#' );
    				            url = hash[0] + separator + key + '=' + value;
    				            if ( typeof hash[1] !== 'undefined' && hash[1] !== null )
    				                url += '#' + hash[1];
    				            return url;
    				        }
    				        else
    				            return url;
    				    }
    
    				},
    
    				get_query_var: function( name, url, default_val ) {
    
    					if ( ! url ) {
    						return '';
    					}
    
    					if ( ! default_val ) {
    						default_val = null;
    					}
    
    				    name = name.replace(/[\[\]]/g, "\\$&");
    				    var regex = new RegExp(name + "(=([^&#]*)|&|#|$)"),
    				        results = regex.exec(url);
    				    if (!results) return default_val;
    				    if (!results[2]) return default_val;
    				    return decodeURIComponent(results[2].replace(/\+/g, " "));
    				}
    			};
    
    			$( document ).ready(function(){
    				WPMUDEV_App_Admin_Orderby_client.load();
    			});
    
     		})(jQuery);
     	</script>
    	<?php
    } );

    You can paste the above snippet in a mu-plugin or your child theme's functions.php file. In case you are not familiar with mu-plugins you can read about them here :
    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/
    In case you prefer to use the functions.php file instead, make sure you are using a child theme so you don't lose your custom snippets on theme update.

    Hope this helps!
    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.