Edit order of services in dropdown menu

I sometimes need to add services to my Appointments+ services but I need to place them along with other services from that same group. Which file can I manually edit to add services each time? Otherwise, new services are just added at the bottom.

  • more

    Do you know how a user needs to select a service on A+ from a dropdown menu? Those services are added by me via the backend on the A+ > Settings > Services page. Each time I click on "Add New Service" it will add a new service at the bottom of the list, or the bottom of the dropdown menu that will appear to the user on the booking page.

    My services are divided into groups and certain services need to be added to groups which are not at the bottom of the list.

    I remember that there is a document somewhere I can access via FTP and change the number and order of the services to edit the list to fit my needs.

    I am asking if you could point me to the right file so I can do that every time I have a new service to add.

    Thank you.

  • more

    It is possible. I'm not so sure if it was Hakan or the developer that took over A+, who told me a few months ago to go to a certain location and just manually edit my services list. Unfortunately, I can not find that message. It might have gotten lost when I became an Elite member. When you add anything via WP admin, that data is stored somewhere, you just need to know where and can edit it manually. I clearly remember doing it before, I rearranged my whole services list assigning different number to each srvice so they will be sorted properly in dropdown menu website users see.

    Please help,

    Thank you.

  • Vladislav

    Hello,

    As @aristath said, the services are stored in the database, so there isn't a file you can change to re-order them. You can, however, achieve what you need with some custom code. Just before the drop-down list is generated, the services list will be passed through a filter named "app_services". You can hook up to this filter and re-order your services in any way you need them shown. The first and only argument passed to the function hooked up to this filter will be a PHP array of services and whatever this function returns will be used as a list of services when generating your drop-down field. I hope this helps.

  • Vladislav

    Hello,

    Like I said in my previous post, this can already be done, with just a little bit of custom code. I do apologise for not including a code example before, but here's one now:

    function my_app_compare_service_capacities ($a, $b) {
    	return $a->capacity == $b->capacity
    		? 0
    		: ($a->capacity < $b->capacity ?  -1 : 1)
    	;
    }
    function my_app_order_services ($srv) {
    	usort($srv, 'my_app_compare_service_capacities');
    	return $srv;
    }
    add_filter('app_services', 'my_app_order_services');

    This code snippet will hook up to "app_services" filter and re-order them according to their respective capacities. The "my_app_order_services" function is where this is being set up. The "my_app_compare_service_capacities" function is the "comparator" function - a helper function that performs the actual comparison between the service capacities, which is then used for sorting. I hope this helps.

  • Tyler Postle

    Hey again Dom!

    Thanks for the question. Currently you can order by ID or Name in either ascending or descending order, like this:

    [app_services order_by="name DESC"]

    Would that work? Otherwise Ve's code above should help :slight_smile: you can place that into your functions.php theme file.

    Then you can order the services based on capacity you have set for them I believe. If you go to Appointments > Seervices tab then you can set the capacity there.

    Hope this helps! Let us know if you need any further assistance.

    Cheers,
    Tyler

    PS. In the future if you can open a new thread instead of bringing up an old one that would be appreciated. You will receive more efficient support that way too because it keeps all your posted questions organized. You can always link to old threads of course, that information helps too :slight_smile:

  • wiscwebwriter

    It would be very helpful to be able to reorder services and service providers both by a normal A to Z sort but also custom with a drag and drop functionality. The current set up is not conducive to having a professional looking list if they should be sorted in a specific manner.

    I will need to reenter most of the services list if I add something and I want it in the middle of the current list. I doubt I can do that once this is being used for appointments because I would be deleting and re-adding services.

    I have over 150 service providers. I want them to appear alphabetically! Not in the order entered. This is not going to work well at all.

  • Michelle Shull

    Hi wiscwebwriter!

    It would be great if you could open your own thread about this issue, as Tyler mentioned in the post above yours:

    PS. In the future if you can open a new thread instead of bringing up an old one that would be appreciated. You will receive more efficient support that way too because it keeps all your posted questions organized. You can always link to old threads of course, that information helps too :slight_smile:

    But, since we're already here, a slightly different version of the shortcode above does do exactly what you want, it allows you to list your providers alphabetically.

    [app_service_providers order_by="name DESC"]

    Hope this helps!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.